2011年11月13日
摘要: #include <iostream>#include <string>using namespace std;int main(){ void max_string(char str[][30],int i);int i;char country_name[3][30];for(i=0;i<3;i++)cin>>country_name[i];max_string(country_name,3);return 0;}void max_string(char str[][30],int n){int i;char string[30];strcpy(s 阅读全文
posted @ 2011-11-13 22:37 Gavin Dai 阅读(182) 评论(0) 推荐(0) 编辑
摘要: #include <cmath>#include <iostream>using namespace std;float f(float x){return x * x * x - 5 * x *x + 16 * x - 80;}void main(void){float x1, x2, x0, f0, f1, f2;do {cout<<"Input x1, x2\n";cin>>x1>>x2;f1 = f(x1);f2 = f(x2);} while (f1 * f2 > 0);do {x0 = ( x1 阅读全文
posted @ 2011-11-13 22:01 Gavin Dai 阅读(253) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;class Date;class Time{public:Time(int,int,int);void display(const Date&);private:int hour;int minute;int sec;};class Date{public:Date(int,int,int);friend void Time::display(const Date &);private:int month;int day;int year;};Time::Time(int h,int m, 阅读全文
posted @ 2011-11-13 21:36 Gavin Dai 阅读(3410) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;class Time{public:Time(int,int,int);int hour;int minute;int sec;void get_time();};Time::Time(int h,int m,int s){hour=h;minute=m;sec=s;}void Time::get_time(){cout<<hour<<":"<<minute<<":"<<sec<<endl;}i 阅读全文
posted @ 2011-11-13 20:27 Gavin Dai 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 函数分声明和定义,但是如果声明和定义是在一些起的,相当于没有声明的话,默认参数与inline就只要写在定义中就可以了。但是如果函数如果先声明后定义的话,默认参数只能写在声明中,定义时不能再写上默认参数。inline在声明中写,定义时可写可不写. 阅读全文
posted @ 2011-11-13 15:10 Gavin Dai 阅读(284) 评论(0) 推荐(0) 编辑