欢迎来到天天文库
浏览记录
ID:27191465
大小:699.50 KB
页数:74页
时间:2018-12-01
《《程序设计基础——c++》》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《程序设计基础——C++》例1.1#includevoidmain(){cout<<“Hello,C++!”<voidmain(){doubles,r;cout<<“Inputtheradium:r=”;cin>>r;s=3.14159*r*r;cout<<“r=”<intadd2(intx,inty);voidmain(){inta,b,c;ci
2、n>>a>>b;c=add2(a,b);cout<<“它们的和为”<classdog{private:char*name;intage;74charsex;public:dog(char*n,inta=0,chars='m');voidspeak();};dog::dog(char*n,inta,chars){name=n;age=a;sex=s;}voiddog::speak(){cout<<"Mynam
3、eis"<constfloatPI=3.14159;voidmain(){floats,r;cout<<“Inputtheradium:r=”;cin>>r;s=PI*r*r;cout<<“theareais”<4、voidmain(){intx=20,z;z=++x;z+=x;cout<<“Firsttime:Z=”<voidmain(){floatf,x=3.6,y=5.2;inti=4,a,b;a=x+y;b=(int)x+y;f=10/i;cout<<“a=”<5、;}例2.1 #includevoidmain(){inta,b;floatx,y;cout<<“Enter2integers:”;cin>>a>>b;cout<<“Enter2floatdata:”;cin>>x>>y;cout<voidmain(){charx,y;cout<<“Enter2characters:”<>x>>y;putchar(x);putchar(y);}例26、.3 。#includevoidmain(){charc1, c2;charstring[20]=“Howareyou?”;cin>>c1>>c2;++c1;--c2;cout<voidmain(){intx;cout<<“inputanumber:”<>x;if(x==8) cout<<“x=8”<voidmai7、n(){charch;cout<<“inputacharacter:”<>ch;if(ch>=’0’&&ch<=’9’)cout<<“Itisanumber.”;elsecout<<“Itisnotanumber.”;}例2.7#includevoidmain(){ intscore;cout<<“enteryourscore:”<>score;cout<<”score=”<=90)cout<<“A”<8、=80)cout<<“B”<=70)cout<<“C”<
4、voidmain(){intx=20,z;z=++x;z+=x;cout<<“Firsttime:Z=”<voidmain(){floatf,x=3.6,y=5.2;inti=4,a,b;a=x+y;b=(int)x+y;f=10/i;cout<<“a=”<5、;}例2.1 #includevoidmain(){inta,b;floatx,y;cout<<“Enter2integers:”;cin>>a>>b;cout<<“Enter2floatdata:”;cin>>x>>y;cout<voidmain(){charx,y;cout<<“Enter2characters:”<>x>>y;putchar(x);putchar(y);}例26、.3 。#includevoidmain(){charc1, c2;charstring[20]=“Howareyou?”;cin>>c1>>c2;++c1;--c2;cout<voidmain(){intx;cout<<“inputanumber:”<>x;if(x==8) cout<<“x=8”<voidmai7、n(){charch;cout<<“inputacharacter:”<>ch;if(ch>=’0’&&ch<=’9’)cout<<“Itisanumber.”;elsecout<<“Itisnotanumber.”;}例2.7#includevoidmain(){ intscore;cout<<“enteryourscore:”<>score;cout<<”score=”<=90)cout<<“A”<8、=80)cout<<“B”<=70)cout<<“C”<
5、;}例2.1 #includevoidmain(){inta,b;floatx,y;cout<<“Enter2integers:”;cin>>a>>b;cout<<“Enter2floatdata:”;cin>>x>>y;cout<voidmain(){charx,y;cout<<“Enter2characters:”<>x>>y;putchar(x);putchar(y);}例2
6、.3 。#includevoidmain(){charc1, c2;charstring[20]=“Howareyou?”;cin>>c1>>c2;++c1;--c2;cout<voidmain(){intx;cout<<“inputanumber:”<>x;if(x==8) cout<<“x=8”<voidmai
7、n(){charch;cout<<“inputacharacter:”<>ch;if(ch>=’0’&&ch<=’9’)cout<<“Itisanumber.”;elsecout<<“Itisnotanumber.”;}例2.7#includevoidmain(){ intscore;cout<<“enteryourscore:”<>score;cout<<”score=”<=90)cout<<“A”<
8、=80)cout<<“B”<=70)cout<<“C”<
此文档下载收益归作者所有