菜鸟小鱼的路程
jimmy0603
今天的生活是三年前的选择
三年后的生活是今天的决定
展开
-
菜鸟小鱼啄定C++
菜鸟小鱼啄定C++慢慢学习-ing 每天看一些 就发到这里来 纯菜鸟 见笑。原创 2008-05-09 17:46:00 · 498 阅读 · 0 评论 -
7章4节break和continue
#include int main (){ using namespace std; typedef unsigned long ULONG; ULONG small,large,skip,target; const unsigned short MAXSMALL=65535; cout cin >> small; cout cin >> large; cout cin >>原创 2008-05-11 04:25:00 · 253 阅读 · 0 评论 -
5章5节去顶函数的作用域温度转换
#include float convert(float);int main(){ using namespace std; float tempfer; float tempcel; cout cin >> tempfer; tempcel=convert(tempfer); cout cout char response;cin >> response; return原创 2008-05-11 01:06:00 · 526 阅读 · 0 评论 -
4章10节输入一个大于一百小于十的数字
#include int main(){ using namespace std; int x; cout cin >> x; if (x >=10) { if(x>100) cout else cout } else cout return 0;}原创 2008-05-11 01:00:00 · 697 阅读 · 0 评论 -
4章9节三目运算符
#include int main(){ using namespace std; int x,y,z; cout cin >> x; cin >> y; z = (x>y) ? x: y; cout // ?: 为条件运算符 是唯一一个需要三个操作数的运算符 /* 用if表示等同于下 if(x>y) z=x cout else z=y cout */原创 2008-05-11 00:56:00 · 369 阅读 · 0 评论 -
4章6节运算优先级括号嵌套返回值
#include int main(){/* 优先级 1. 解析运算符 :: 2. 成员选择 下标 函数调用 后缀递增递减 . -> () ++ -- 3. sizeof 前缀递增递减 求补 逻辑非 单目加和减 取址和解除引用 new new[] delete delete[] 强制类型转换 sizeof() ++ -- …… ! + - & ()原创 2008-05-11 00:49:00 · 384 阅读 · 0 评论 -
4章1节语句和表达式
#include int main(){ using std::cout; using std::endl; int a=0,b=1,x=1,y=22; cout cout {a=2; b=3; y=x=a+b; } // 这是一个语句块 就是一个简单的语句也可以拆分为几个语句 用{}来括起来表示 cout cout char reponse; std::cin>>re原创 2008-05-10 16:52:00 · 218 阅读 · 0 评论 -
3章8节常量的定义
#include // 每个班级有15个学生 定义两个量 students = classes*15// 如果用 studensperclass 代表15 那么 students = classes*studensperclass //定义方法 有#define 和 #const#define studentsperclass = 15; //#define 是简单的文本替换 遇见studen原创 2008-05-10 16:46:00 · 191 阅读 · 0 评论 -
7章5节一些荒谬的空for循环
#include int main(){ using namespace std; int counter = 0; int max; cout cin >> max; for( ; ; ) //空for 没有初始化 没有条件 没有action 但是还是要有( ; ; ) { if (counter { cout counter++; } else b原创 2008-05-11 04:35:00 · 349 阅读 · 0 评论 -
7章4节实现dowhile
#include int main(){ int counter; std::cout std::cin >> counter; while(counter>0) { std::cout counter--; } std::cout return 0;}原创 2008-05-11 04:27:00 · 281 阅读 · 0 评论 -
7章4节使用dowhile
#include int main(){ int counter; std::cout std::cin >> counter; do { std::cout counter--; } while(counter>0);//while和do while的区别在于是先执行程序还是先判断是否要执行 // do while中不管原创 2008-05-11 04:28:00 · 307 阅读 · 0 评论 -
8章6节删除自由存储区的对象
#includeiostream>using namespace std;class SimpleCat...{public: SimpleCat(); ~SimpleCat();private: int itsAge;};SimpleCat::SimpleCat()...{ cout "Constructor called." endl; itsA原创 2008-05-16 23:13:00 · 305 阅读 · 0 评论 -
8章9节this指针
#include iostream>class Rectangle...{public: Rectangle(); ~Rectangle(); void SetLength(int length) ...{this->itsLength=length;} int GetLength()const ...{return this->itsLength原创 2008-05-16 23:18:00 · 281 阅读 · 0 评论 -
8章3节分配删除指针new和delete
#includeiostream>int main()...{ using namespace std; int localVariable = 5; int*pLocal = &localVariable; int *pHeap = new int; *pHeap = 7; cout "localVariable: " localVariab原创 2008-05-16 23:10:00 · 392 阅读 · 0 评论 -
8章1节确定指针中存储的内容
#include iostream>int main()...{ using namespace std; unsigned short int myAge=20 , yourAge=30; unsigned short int *pAge=&myAge; cout "myAge is: "myAge; cout " yourAge is: "you原创 2008-05-16 23:09:00 · 342 阅读 · 0 评论 -
8章7节访问数据成员
#includeiostream>class SimpleCat...{public: SimpleCat() ...{itsAge = 2;} ~SimpleCat()...{} int GetAge() const ...{return itsAge;} void SetAge(int age) ...{itsAge = age; } privat原创 2008-05-16 23:14:00 · 298 阅读 · 0 评论 -
学习十天的复习程序
#include iostream>using namespace std;enum CHOICE...{ DrawRect = 1, GetArea, GetPerim, ChangeDimensions, Quit};class Rectangle...{pub原创 2008-05-13 02:26:00 · 292 阅读 · 0 评论 -
7章5节for语句的循环
#include int main(){ int counter; for(counter=0;counter /* for 循环 (initialization; test; action) 由三个部分组成 初始化 测试 执行的动作(如递增)相当与 int counter =0; .......initialization w原创 2008-05-11 04:34:00 · 239 阅读 · 0 评论 -
7章5节for语句2个参数的循环
#include int main(){ for(int i =0 ,j = 100 ; i { std::cout } // for 和while 一样可以作为一个条件的中断 跳出当前的循环 去执行下一个action std::cout return 0;}原创 2008-05-11 04:32:00 · 832 阅读 · 0 评论 -
7章2节while循环
#include int main (){ using namespace std;int counter = 100;while (counter { counter++; cout }cout return 0;}原创 2008-05-11 04:24:00 · 268 阅读 · 0 评论 -
7章1节goto循环
#include int main(){ using namespace std; int counter =100; int n; loop: n = counter++; cout if (n goto loop; cout return 0;}原创 2008-05-11 01:27:00 · 234 阅读 · 0 评论 -
3章9节枚举变量
#include int main(){ enum days { sunday,monday,tuesday,wednsday,thursday,friday,saturday,};// rnum 枚举函数 days 包含七个可取数值 数值用大括号 逗号 隔开 // 不制定特殊值 那么第一个可取值既为 0 依次。。。如: // enum colour {red,blue,green=100,原创 2008-05-10 16:51:00 · 284 阅读 · 0 评论 -
3章5节typ创建别名
#include int main(){ using std::cout; using std::endl; short unsigned int width = 5, length; length = 10; // 定义变量和赋值变量可以一次多个 并可以混合 unsigned short int area = (width * length); cout cout原创 2008-05-09 21:52:00 · 229 阅读 · 0 评论 -
2章5节使用函数
#include int Add (int first,int second){ std::cout return (first + second);}int Subtract (int third,int forth){ std::cout return (third - forth);}int main(){ using namespace std; cout int a,b,c原创 2008-05-09 21:35:00 · 208 阅读 · 0 评论 -
2章3节using应用
#includeint main(){ using std::cout; using std::endl; /* using “/* ” 之间的东西为注释 可以是多行的注释 // 表示单行的注释 */ cout cout cout cout cout cout cout cout cout return 0原创 2008-05-09 21:32:00 · 282 阅读 · 0 评论 -
2章2节cout应用
#include int main(){ std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::cout std::原创 2008-05-09 21:29:00 · 220 阅读 · 0 评论 -
1章练习题加法乘法
#include int main(){ int x=5; int y=7; std::cout std::cout return 0;}原创 2008-05-09 21:12:00 · 231 阅读 · 0 评论 -
3章7节使用ASCII码字符
#include int main(){ for (int i = 32; i std::cout char response; std::cin >> response; /* char response; std::cin >> response; 是用来暂停程序.exe执行的 */ return 0;}/* /a 响铃原创 2008-05-09 21:55:00 · 214 阅读 · 0 评论 -
1章 打印不同字符
#include int main(){ using namespace std; cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout char response; std::cin >> response;原创 2008-05-09 21:03:00 · 224 阅读 · 0 评论 -
4章5节递增递减前后缀的区别
#include int main(){ using namespace std; int myage =23, yourage=30; cout cout myage++; //后缀是先赋值再递减1 ++yourage;//前缀是先递增再赋值1给前面的myage cout cout cout myage++; ++yourage; cout cout c原创 2008-05-11 00:47:00 · 375 阅读 · 0 评论 -
5章1节函数的声明定义用法
#include int area( int length,int width);// 声明一个函数 包括 返回值的类型 函数名 函数包括的参数int main(){ using namespace std; int lengthofyard; int widthofyard; int areaofyard; cout cin >>widthofyard; cout cin原创 2008-05-11 01:02:00 · 253 阅读 · 0 评论 -
6章16节练习3表示工资
#include class Employee{ public: int GetAge () const; void SetAge (int age); int GetYearsOfService () const; void SetYearsOfService (int years); int GetSalary () const; void SetSalary (int salar原创 2008-05-11 01:26:00 · 310 阅读 · 0 评论 -
6章12节做一个.h头文件
#include class Cat{public: Cat(int initialage); ~Cat(); int GetAge(); void SetAge(int age); void Meow();private: int itsAge;}; #include "123.h" Cat::Cat(int initialage) //constructor原创 2008-05-11 01:24:00 · 310 阅读 · 0 评论 -
5章10节递归
#include int fib (int n);using namespace std;int main(){ int n, answer; cout cin >> n; cout answer=fib(n); cout cout return 0;}int fib (int n){ cout if(n { cout return (原创 2008-05-11 01:12:00 · 184 阅读 · 0 评论 -
4章9节if比较大小
#include int main(){ using namespace std; int bignumber,smallnumber; cout cin >> bignumber; cin >> smallnumber; if (bignumber>smallnumber) { cout } if(bignumber { bignumber=smalln原创 2008-05-11 00:53:00 · 393 阅读 · 0 评论 -
4章3节使用运算符
#include int main(){ using std::cout; using std::endl; int difference,bignumber=100,smallnumber=50; difference=bignumber-smallnumber; cout difference=smallnumber-bignumber; cout原创 2008-05-11 00:46:00 · 209 阅读 · 0 评论 -
7章7节使用swich控制语句
#include int main(){ using namespace std; unsigned short int number; cout cin >> number; switch (number) // 下面假设了5个条件 { case 0: cout break; case 5: cout break; case 4: cout原创 2008-05-11 23:29:00 · 585 阅读 · 0 评论 -
7章6节for循环计算Fibonacci数
#include unsigned int fib(unsigned int position);int main(){ using namespace std; unsigned int answer,position; cout cin >> position; cout answer = fib(position); cout cout return 0;}原创 2008-05-11 04:36:00 · 332 阅读 · 0 评论 -
5章10节递归
#include int fib (int n);using namespace std;int main(){ int n, answer; cout cin >> n; cout answer=fib(n); cout cout return 0;}int fib (int n){ cout if(n { cout return (原创 2008-05-11 01:11:00 · 246 阅读 · 0 评论 -
章8节在自由存储区中创建成员
#includeiostream>class SimpleCat...{public: SimpleCat(); ~SimpleCat(); int GetAge() const ...{return *itsAge;} void SetAge(int age) ...{*itsAge=age;} int GetWeight() const ...{re原创 2008-05-16 23:17:00 · 367 阅读 · 0 评论