C++课程学习代码汇总基础

写在开头的话:

         今天难得一天没课。打算把之前学习过的课程再重新看一遍。写了好多代码,编译运行之后都删掉写下一个了。

         久而久之不免觉得浪费,现在把它们都贴在下面把。就跟看着自己的孩子一样。说不定以后有利用的价值,没事儿还可以翻出来看看。

(不定时补充



发现好像写了蛮多的,在1楼做一个目录吧。方便以后的查阅。

  1. 文字信息统计
  2. 冒泡排序
  3. 简易计算器
  4. 使用string字符串替换拼接字符中的单词
  5. 三位逆序数
  6. 使用string取子字符串
  7. 词频统计
  8. 求三个数中的最大数
  9. Hanoi汉诺塔问题
  10. 利用指针实现三个数的排序
  11. 利用字符指针删除字符首部的空格
  12. 钟表类的完整定义
  13. 日期类的完整定义
  14. 分数运算函数的完整定义
  15. 可鸣笛、运动和播放MP3的汽车类定义
  16. 设计平面上的几何图形:圆
  17. 学生信息类1.0
  18. 学生信息类2.0
  19. 日期类的定义(构造函数版)
  20. 日期类的定义(重载构造函数版)
  21. 日期类的定义(析构函数版)
  22. 能翻译整数的机器人1.0
  23. 能翻译整数的机器人2.0
  24. Person类的定义
  25. this指针使用的例子
  26. 日期类输出定义
  27. person类(singer)综合定义
  28. person类继承Date类和Time类
  29. 智能手机类定义

下面是代码的集合:

  1. 文字信息统计
    #include
    using namespace std;
    int main()
    {
    	const int N=100;
    	char str[N];
    	int len=0,capital=0,smallletter=0,digit=0,others=0;
    	cout<<"Please input the sentence:"<='A'&&str[i]<='Z'){
    			capital++;
    		}
    		else if(str[i]>='a'&&str[i]<='z'){
    			smallletter++;
    		}
    		else if(str[i]>='0'&&str[i]<='9'){
    			digit++;
    		}
    		else{
    			others++;
    		}
    		i++;
    	}
    	cout<<"please wait..."<

  2. 冒泡排序
    #include
    #include
    using namespace std;
    int main()
    {
    	int N,i,j;
    	double a[100];
    	cout<<"Please input the number of tested numbers:"<>N;
    	cout<<"Please input the tested numbers:"<>a[i];
    	}
    	for(i=0;ia[j+1]){
    				int tmp;
    				tmp=a[j];
    				a[j]=a[j+1];
    				a[j+1]=tmp;
    			} 
    		}
    	}
    	cout<<"Please wait..."<

  3. 简易计算器
    #include
    #include
    using namespace std;
    int main()
    {
    	int num1,num2,result;
    	char op;
    	char s1[30]="Error!Divided by 0!";
    	char s2[30]="Wrong Expression!";
    	cout<<"Please input the expression:"<>num1>>op>>num2;
    	switch(op)
    	{
    		case'+':
    			result=num1+num2;
    			cout<

  4. 使用string字符串替换拼接字符中俄单词
    #include
    #include
    using namespace std;
    int main()
    {
    	string text1("Heavy rains are pushing water levels beyoud the limit.");
    	string text2,text3;
    	int k;
    	text2="Sluice gates at Three Gorges Dam opened to discharge water.";
    	text3=text1+text2;
    	k=text3.find("Heavy");
    	text3.erase(k,sizeof("Heavy")-1);
    	text3.insert(k,"Strong");
    	cout<

  5. 三位逆序数
    #include
    using namespace std;
    int main()
    {
    	int a,b,c,n;
    	cout<<"Please input a three-digit number:"<>n;
    	a=n%10;
    	b=(n/10)%10;
    	c=n/100;
    	cout<<"the inversion number is "<

  6. 使用string取子字符串
    #include
    using namespace std;
    int main()
    {
    	char str[101];
    	char sub[101];
    	int len,k,l;
    	int i,j=0;
    	cout<<"Please input the sentence:"<>k>>l;
    	while(k!=0&&l!=0){
    		j=0;
    		for(i=k-1;i>k>>l;
    	}
        return 0;
    }

  7. 词频统计
    #include
    #include
    using namespace std;
    struct WordList{
    	char word[20];
    	int freq;
    };
    int main()
    {
    	WordList list[1000];
    	int N=0;
    	int i,j,k;
    	char tmp[20];
    	cout<<"Please input some English words,and input 'xyz' to end."<>tmp;
    	while(strcmp(tmp,"xyz")!=0){
    		for(i=0;i=N){
    			strcpy(list[i].word,tmp);
    			list[i].freq=1;
    			N++;
    		}
    		cin>>tmp;
    	}
    	for(i=0;i

  8. 求三个数中的最大数
    #include
    using namespace std;
    double maxThree(double a,double b,double c)
    {
    	double max;
    	max=a>b?a:b;
    	max=max>c?max:c;
    	return max;
    }
    int main()
    {
    	double x1,x2,x3;
    	double max;
    	cout<<"Please input 3 numbers:"<>x1>>x2>>x3;
    	max=maxThree(x1,x2,x3);
    	cout<<"The biggest number is "<

  9. Hanoi汉诺塔问题
    //教材中将两个自定义void函数放在了main函数之后,但是由于个人习惯,我还是将main函数放在了最后 
    #include
    using namespace std;
    void hanoi(int n,int p1,int p2,int p3)
    {
    	void move(int,char,char);
    	if(n==1){
    		move(n,p1,p3);
    	}
    	else{
    		hanoi(n-1,p1,p3,p2);
    		move(n,p1,p3);
    		hanoi(n-1,p2,p1,p3);
    	} 
    }
    void move(int n,char from,char to)
    {
    	cout<>n;
    	void hanoi(int,int,int,int);
    	hanoi(n,'A','B','C');
    	cout<

  10. 利用指针实现三个数的排序
    #include
    using namespace std;
    void  swap(int *px,int *py)
    {
    	int t=*px;
    	*px=*py;
    	*py=t;
    }
    int main()
    {
    	int a,b,c;
    	cout<<"Please input 3 numbers:"<>a>>b>>c;
    	int *pa=&a;
    	int *pb=&b;
    	int *pc=&c;
    	if(*pa>*pb){
    		swap(pa,pb);
    	}
    	if(*pa>*pc){
    		swap(pa,pc);
    	}
    	if(*pb>*pc){
    		swap(pb,pc);
    	}
    	cout<<"The correct order is: "<

  11. 利用字符指针删除字符首部的空格
    #include
    using namespace std;
    char *ltrim(char s[])
    {
    	int k,j;
    	k=0;
    	while(s[k]==' '){
    		k++;
    	}
    	j=k;
    	while(s[j]!='\0'){
    		s[j-k]=s[j];
    		j++;
    	}
    	s[j-k]='\0';
    	return &s[0];
    }
    int main()
    {
    	char str[100];
    	cout<<"请输入首部带一个或若干个空格的字符:"<

  12. 钟表类的完整定义
    #include  
    #include  
    using namespace std;  
    class Clock  
    {  
        private:  
            int Hour;  
            int Minute;  
            int Second;  
            float Price;  
        public:  
            void Set(int h,int m,int s,float p);  
            void Run();  
            void Report_Time();  
            void Show_Time(){cout<

  13. 日期类的完整定义
    #include  
    #include  
    using namespace std;  
    class Date  
    {  
        private:  
            int year,month,day;  
            void SetSystemDate();          //取得系统日期   
        public:  
            void init(int,int,int);  
            void print_ymd();  
            void print_mdy();  
            int get_year(){return year;}  
            int get_month(){return month;} //上中下均为内联函数   
            int get_day(){return day;}  
            bool IsLeapYear();             //判断是否为闰年   
    };  
    void Date::SetSystemDate()  
    {  
        tm *gm;                                //tm是时间结构体   
        time_t t=time(NULL);                   //time_t是长整型   
        gm=gmtime(&t);  
        year=1900+gm->tm_year;  
        month=gm->tm_mon+1;  
        day=gm->tm_mday;   
    }  
    void Date::init(int yy,int mm,int dd)          //有效性检验   
    {  
        if(yy>=1900&&yy<=9999)  
            year=yy;  
        else  
        {  
            SetSystemDate();  
            return;  
        }  
        if(mm>=1&&mm<=12)  
            month=mm;  
        else  
        {  
            SetSystemDate();  
            return;  
        }  
        if(dd>=1&&dd<=31)  
            day=dd;  
        else  
        {  
            SetSystemDate();  
        }  
        return;   
    }   
    void Date::print_ymd()  
    {  
        cout<

  14. 分数运算函数的完整定义
    #include  
    #include  
    using namespace std;  
    class Fraction  
    {  
        protected:  
            int a;    //分子定义成保护成员  
            int b;    //分母因为不能为0,因此定义为私有成员  
            int divisor(int p,int q);  // 求最大公约数  
        public:  
            void set(int aa,int bb);   
            void show();  //显示分数  
            Fraction add(Fraction u); //加一个分数          
    };  
    void Fraction::set(int aa,int bb)  
    {  
        a=aa;  
        if(bb!=0){  
            b=bb;  
        }  
        else{  
            a=0;  
            b=1;  
        }  
    }  
    void Fraction::show()  
    {  
        cout<>a;
    }
    int main()
    {
    	automobile nison;
    	char tp[]="yyida";
    	char ys[]="white";
    	nison.set_data(tp,ys,200000,5,3);
    	nison.horming(5);
    	nison.movecar(10,3);
    	nison.downcar(8);
    	char mp[]="d:\\宋冬野 - 董小姐.flac";
    	nison.play_mp3(mp);
    	return 0; 
    }
    

  15. 设计平面上的集合图形:圆
    #include
    using namespace std;
    class Point
    {
    	private:
    		int x,y;        //如不写private则默认为私有成员 
    	public:
    		void InitPoint(int,int);
    		int GetX(){return x;}
    		int GetY(){return y;}
    		void print();
    };
    void Point::InitPoint(int a,int b)
    {
    	x=a;
    	y=b;
    }
    void Point::print()
    {
    	cout<<"["<0?r:0);          //有效性检验 
    	Center=p;
    }
    double Circle::GetRadius()
    {
    	return radius;
    }
    Point Circle::GetCenter()
    {
    	return Center;
    }
    double Circle::Area()
    {
    	return 3.14159*radius*radius;
    }
    void Circle::Print()
    {
    	cout<<"Center=";
    	Center.print();
    	cout<<";  Radius="<

  16. 学生信息类1.0
    #include
    #include
    using namespace std;
    //设置信息函数Set_info
    class Info
    {
    	private:                 //我还是喜欢把private打出来 
    		int Id;
    	    char Name[20];
    	    int Programming;
    	    int Network;
    	    int Database;
    	    int Total;
    	public:
    		void Set_info(int id,char *name,int programming,int network,int database);
    	    int Get_Pro();
    	    int Get_Net();
    	    int Get_Dat();
    	    int Get_Tol();
    	    void Show();
    };
    void Info::Set_info(int id,char *name,int programming,int network,int database)
    {
    	Id=id;
    	strcpy(Name,name);
    	Programming=programming;
    	Network=network;
    	Database=database;
    	Total=programming+network+database;
    } 
    int Info::Get_Pro()
    {
    	return Programming;
    }
    int Info::Get_Net()
    {
    	return Network;
    }
    int Info::Get_Dat()
    {
    	return Database;
    }
    int Info::Get_Tol()
    {
    	return Total;
    }
    //显示信息函数Show 
    void Info::Show()
    {
    	cout<>id>>name>>programming>>network>>database;
    		student[i].Set_info(id,name,programming,network,database);
    	}
    	cout<<"学号 姓名 程序设计 计算机网络 数据库 总分"<

  17. 学生信息类2.0
    #include
    #include
    using namespace std;
    //设置信息函数Set_info
    class Info
    {
    	private:                 //我还是喜欢把private打出来 
    		int Id;
    	    char Name[20];
    	    int Programming;
    	    int Network;
    	    int Database;
    	    int Total;
    	public:
    		void Set_info(int id,char *name,int programming,int network,int database);
    	    int Get_Pro();
    	    int Get_Net();
    	    int Get_Dat();
    	    int Get_Tol();
    	    void Show();
    };
    void Info::Set_info(int id,char *name,int programming,int network,int database)
    {
    	Id=id;
    	strcpy(Name,name);
    	Programming=programming;
    	Network=network;
    	Database=database;
    	Total=programming+network+database;
    } 
    int Info::Get_Pro()
    {
    	return Programming;
    }
    int Info::Get_Net()
    {
    	return Network;
    }
    int Info::Get_Dat()
    {
    	return Database;
    }
    int Info::Get_Tol()
    {
    	return Total;
    }
    //显示信息函数Show 
    void Info::Show()
    {
    	cout<>count;
    	while(count>MAX_COUNT){
    		cout<<"学生人数不能超过"<>count;
    	}
    	cout<<"请输入学生成绩的信息:"<>id>>name>>programming>>network>>database;
    		student[i].Set_info(id,name,programming,network,database);
    	}
    	cout<<"按总分高低排名如下:"<i;j=j-1){
    			if(student[j].Get_Tol()>student[j-1].Get_Tol()){
    				tmp=student[j];
    				student[j]=student[j-1];
    				student[j-1]=tmp;
    			}
    		}
    	}
    	cout<<"学号 姓名 程序设计 计算机网络 数据库 总分"<85&&student[i].Get_Net()>85&&student[i].Get_Dat()>85){
    			student[i].Show();
    		}
    	}
    	cout<

  18. 日期类的定义(构造函数版)
    #include
    using namespace std;
    class Date
    {
    	private:
    		int year,month,day;
    	public:
    		Date(int y=1900,int m=1,int d=1)     //名字相同,这就是构造函数 
    		{
    			year=y;
    			month=m;
    			day=d;
    		}
    		void init(int,int,int);
    		void print_ymd();
    		void print_mdy();
    };
    void Date::init(int yy,int mm,int dd)     //有效性检验 
    {
    	month=(mm>=1&&mm<=12)?mm:1;
    	year=(yy>=1900&yy<=9999)?yy:1900;
    	day=(dd>=1&&dd<=31)?dd:1;
    }
    void Date::print_ymd()
    {
    	cout<

  19. 日期类的定义(重载构造函数版)
    #include 
    #include
    #include
    using namespace std;
    class Date
    {
    	private:
    		int year,month,day;
    	public:
    		Date():year(1900),month(1),day(1){};   //无参构造函数
    	    Date(int yy,int mm=1,int dd=1);     //默认参数构造函数 
    		Date(Date &d):year(d.year),month(d.month),day(d.day){};
    		Date(char *ps);
    		void print_ymd(); 
    };
    Date::Date(int yy,int mm,int dd):year(1900),month(1),day(1)
    {
    	if(yy>=1900&&yy<=9999){          //这段还是有效性检验 
    		year=yy;
    	}
    	else{
    		return;
    	}
    	if(mm>=1&&mm<=12){
    		month=mm;
    	}
    	else{
    		year=1900;
    		return;
    	}
    	if(dd>=1&&dd<=31){
    		day=dd;
    	}
    	else{
    		year=1900;
    		month=1;
    		return;
    	}
     }
     Date::Date(char *ps):year(1900),month(1),day(1)
     {
     	char py[5],pm[3],pd[3];
     	strncpy(py,ps,4);
     	ps=ps+5;
     	strncpy(pm,ps,2);
     	ps=ps+3;
     	strncpy(pd,ps,2);
     	int yy=atoi(py),mm=atoi(pm),dd=atoi(pd);
     	if(yy>=1900&yy<9999){
     		year=yy;
    	}
    	else{
    		return;
    	} 
    	if(mm>=1&&mm<=12){
    		month=mm;
    	}
    	else{
    		year=1900;
    		return;
    	}
    	if(dd>=1&&dd<=31){
    		day=dd;
    	}
    	else{
    		year=1900;
    		month=1;
    		return;
    	}
     }
     void Date::print_ymd()
     {
     	cout<

  20. 日期类的定义(析构函数版)
    #include
    #include
    #include
    using namespace std;
    class Date
    {
    	private:
    		int year;int month;int day;
    	public:
    		Date():year(1900),month(1),day(1){}
    		Date(int yy,int mm=1,int dd=1);
    		Date(Date &d):year(d.year),month(d.month),day(d.day){};
    		Date(char *ps);       //字符串日期构造函数 
    		void print_ymd();
    		~Date()
    		{
    			static int i=1;
    			cout<<"撤销日期对象"<=1900&&yy<=9999){          //这段还是有效性检验   
            year=yy;  
        }  
        else{  
            return;  
        }  
        if(mm>=1&&mm<=12){  
            month=mm;  
        }  
        else{  
            year=1900;  
            return;  
        }  
        if(dd>=1&&dd<=31){  
            day=dd;  
        }  
        else{  
            year=1900;  
            month=1;  
            return;  
        }  
     }  
     Date::Date(char *ps):year(1900),month(1),day(1)  
     {  
        char py[5],pm[3],pd[3];  
        strncpy(py,ps,4);  
        ps=ps+5;  
        strncpy(pm,ps,2);  
        ps=ps+3;  
        strncpy(pd,ps,2);  
        int yy=atoi(py),mm=atoi(pm),dd=atoi(pd);  
        if(yy>=1900&yy<9999){  
            year=yy;  
        }  
        else{  
            return;  
        }   
        if(mm>=1&&mm<=12){  
            month=mm;  
        }  
        else{  
            year=1900;  
            return;  
        }  
        if(dd>=1&&dd<=31){  
            day=dd;  
        }  
        else{  
            year=1900;  
            month=1;  
            return;  
        }  
     }  
     void Date::print_ymd()  
     {  
        cout<

  21. 能翻译整数的机器人1.0
    #include
    #include
    using namespace std;
    class robot
    {
    	private:
    		char name[20];
    		char type[20];
    	public:
    		robot()
    		{
    			strcpy(name,"XXXXXX");
    			strcpy(type,"XXXXXX");
    		}
    	void set(char n[],char t[])
    	{
    		strcpy(name,n);
    		strcpy(type,t);
    	}
    	void out(int a);
    	void tran_int(int n);
    	~robot(){};
    };
    static char *num1[]=
    {
    	" ","one ","two ","three ","four ","five ","six ","seven ",
    	"eight ","nine ","ten ","eleven ","twelve ","thirteen ",
    	"fourteen ","fifteen ","sixteen ","seventeen ","eighteen ",
    	"nineteen "
    };
    static char *num10[]=
    {
    	" ","twenty ","thirty ","forty ","fifty ","sixty ","seventy ",
    	"eighty ","ninety "
    };
    void robot::out(int a)
    {
    	int b=a%100;
    	if(a/100!=0){
    		cout<1999999999){
    		cout<<"Dev C++ 平台无法处理大于1999999999位的数字!"<>n;
    	cout<

  22. 能翻译整数的机器人2.0
    #include
    #include
    #include
    using namespace std;
    class robot
    {
    	private:
    	    char name[20];
    	    char type[20];
    	    int num;
    	    char *ps;
    	public:
    		robot()     //构造函数 
    		{
    		    strcpy(name,"XXXXXX");
    		    strcpy(type,"XXXXXX");
    		    num=0;
    		    ps=new char[5];
    		    strcpy(ps,"Zero");
    		}
    		void set(char n[],char t[],int m);
    		char *out(int a);
    		char *tran_int(int n);
    		void print_num();
    		~robot(){
    		    cout<<"堆区中"<1999999999){
    		//cout<<"dev C++平台无法处理太大的数字!"<1999999999) else
    	p=new char[strlen(kk)+1];
    	strcpy(p,kk);
    	return p;
    }
    void robot::print_num()
    {
    	cout<<"整数为:"<0){
    		char *tp=tran_int(num);
    		ps=new char[strlen(tp)+1];
    		strcpy(ps,tp);
    		delete[]tp;
    	}
    	else if(num==0){
    		ps=new char[5];
    		strcpy(ps,"Zero");
    	}
    	else{
    		ps=new char[13];
    		strcpy(ps,"负数不能翻译");
    	}
    }
    int main()
    {
    	robot brown;
    	brown.print_num();
    	int n;
    	cout<<"请输入n:";
    	cin>>n;
    	brown.set("brown","800#",n);
    	brown.print_num();
    	cout<

  23. Person类的定义
    #include
    #include
    using namespace std;
    class Person
    {
    	private:
    		char Name[9];
    		char Sex;
    		int Age;
    		char Pid[19];
    		char *Add;
    	public:
    		Person()
    		{
    			strcpy(Name,"XXX");
    			Age=0;
    			Sex=' ';
    			strcpy(Pid,"xxxxxxxxxxxxxxxxxx");
    			Add=NULL;
    		}
    		Person(char *N,int A,char S,char *P,char *Ad)
    		{
    			strcpy(Name,N);
    			Age=A;
    			Sex=S;
    			strcpy(Pid,P);
    			int L=strlen(Ad);
    			Add=new char[L+1];
    			strcpy(Add,Ad);
    		}
    		~Person()
    		{
    			cout<<"Now destroying Person: "<

  24. this指针使用的例子
    #include
    using namespace std;
    class Test
    {
     	private:
     		int x;
     	public:
     		Test(int=0);
     		void print();
    };
    Test::Test(int a)
    {
    	x=a;
    }
    void Test::print()
    {
    	int x=13;
    	cout<<"        x="<x="<x<#include
    using namespace std;
    class Date
    {
    	private:
    		int day,month,year;
    	public:
    		Date(int y=1900,int m=1,int d=1); //构造函数设置默认值 
    		void SetDate(int yy,int mm,int dd);
    		bool IsLeapYear();
    		void print_ymd();
    		void print_mdy();
    };
    Date::Date(int y,int m,int d)
    {
    	SetDate(y,m,d);
    }
    void Date::SetDate(int yy,int mm,int dd)
    {
    	month=(mm>=1&&mm<=12)?mm:1;
    	year=(yy>=1900&&yy<=2100)?yy:1;
    	switch(month)
    	{
    		case 4:
    		case 6:
    		case 9:
    		case 11:
    		    day=(dd>=1&&dd<=30)?dd:1;break;
    		case 2:
    			if(IsLeapYear()){
    				day=(dd>=1&&dd<=29)?dd:1;
    			}
    			else{
    				day=(dd>=1&&dd<=28)?dd:1;
    			}
    			break;
    		default:day=(dd>=1&&dd<=31)?dd:1;
    	}
    }
    bool Date::IsLeapYear()
    {
    	if(year%400==0||(year%100!=0&&year%4==0)){
    		return true;
    	}
    	else{
    		return false;
    	}
    }
    void Date::print_ymd()
    {
    	cout<>a>>b>>c;
    	date.SetDate(a,b,c);
    	cout<<"两种输出格式如下:"<
  25. person类(singer)综合定义
    #include
    #include
    #include
    using namespace std;
    class person
    {
    	private:
    		char *name;
    		char sex;
    		char pid[19];
    		int weight;
    		int high;
    	public:
    		person();    //一个可爱的无参构造函数
    		person(char *n,char s,char *p,int w,int h);
    		void change_data(char *n,char s,char *p,int w,int h);
    		void walking(int k,int v);
    		void hearing(char *sentence);
    		void speaking(int n);
    		void writing();
    		void print();
    		void out(int a);
    		~person(); 
    };
    static char *num1[]=  
    {  
        " ","one ","two ","three ","four ","five ","six ","seven ",  
        "eight ","nine ","ten ","eleven ","twelve ","thirteen ",  
        "fourteen ","fifteen ","sixteen ","seventeen ","eighteen ",  
        "nineteen "  
    };
    static char *num10[]=  
    {  
        " "," ","twenty ","thirty ","forty ","fifty ","sixty ","seventy ",  
        "eighty ","ninety "  
    };  
    void person::print()
    {
    	cout<'a'&&*p<='z'){
    			*p='A'+(*p-'a'+0);     //删掉这个+0试试看 
    		}
    		else if(*p>='A'&&*p<='Z'){
    			*p='a'+(*p-'A');
    		}
    		p++;
    	}
    	cout<1999999999){
    		cout<<"Dev C++平台无法处理太大的数字!"<

  26. person类继承Date类和Time类
    #include
    #include
    #include>
    using namespace std;
    class Date
    {
    protected:
        int day,month,year;
    public:
        Date(){int year=1900,month=1,day=1;}
        Date(int yy,int mm,int dd){init(yy,mm,dd);}
        void init(int,int,int);
        void print_ymd();
        void print_mdy();
    };
    void Date::init(int yy,int mm,int dd)
    {
        month=(mm>=1&&mm<=12)?mm:1;
        year=(yy>=1900&&yy<=2100)?yy:1;
        day=(dd>=1&&dd<=31)?dd:1;
    }
    void Date::print_ymd(){cout<=0&&h<=24)?h:0;
        minute=(m>=0&&m<=60)?m:0;
        second=(s>=0&&s<=60)?s:0;
    }
    void Time::print_time(){cout<'a'&&*p<='z'){
                *p='A'+(*p-'a'+0);
            }
            else if(*p>='A'&&*p<='Z'){
                *p='a'+(*p-'A');
            }
            p++;
        }
        cout<1999999999){
            cout<<"Dev C++平台无法处理太大的数字!"<

  27. 智能手机类定义
    #include
    #include
    using namespace std;
    class mobile
    {
    private:
        char mynumber[12];
        char m_type[40];
        float price;
    public:
        mobile(){init("00000000000","None_type", 0);}
        void init(char *number,char *pt,float pri);
        void dial();
        void answer(char othernumber[]);
        void hangup();
        void show();
    };
    void mobile::init(char *number,char *pt,float pri)
    {
        strcpy(mynumber,number);
        strcpy(m_type,pt);
        price=pri;
    }
    void mobile::dial()
    {
        cout<<"Dialing number is "<

你可能感兴趣的:(Dev,C++学习日志)