i++;}
cout< (3) #include main() {int a[9]={2,4,6,8,10,12,14,16,18}; for(i=0;i<9;i++) { cout< if((i+1)%3= =0) cout< } } (4) #include void LE(int *a,int *b){ int x=*a; *a= *b; *b=x; cout<<*a< ?<<*b< void main() {int x=10,y=25; LE(&x,&y); cout< } (5) #include \ class A{ int a,b; public: A(){a=b=0;} A(int aa,int bb){ a=aa; b=bb; cout< void main() {A x,y(2,3),z(4,5); } (6) #include \ temple TT a1,a2,a3; 11 public: FF(TT b1,TT b2,TT b3){ a1=b1;a2=b2;a3=b3; } TT sum(){return a1+a2+a3;} ]; void main() {FF cout< } (7) #include \ void SB(char ch){ switch(ch){ case ? a?:case ?A ?: cout<<”well!”;break; case ? b?:case ?B ?: cout<<”good!”;break; case ? c?:case ?C ?: cout<<”pass!”;break; default: cout<<”bad!”;break; void main() {char a1=?b?,a2=?C?,a3=?f?; SB(a1);SB(a2);SB(a3);SB(?A?); cout< } 若main()函数改为: void main() {char a[6]=”Abcaf”; for(int i=0;a[i];i++) SB(a[i]); } (8) #include #include *a[5]={“student”,”worker”,”cader”,”solider”,”peasant”}; char p1,p2; p1=p2=a[0]; for(int i=0;i<5;i++) { if(strcmp(a[i],p1)>0) p1=a[i]; if(strcmp(a[i],p2)<0) p2=a[i]; } cout< 12 (9) #include \ int a=5; void main() {int a=10,b=20; cout<,a< ?< for(int i=1;i<6;i++) { a+=i;b+=a;} cout< cout< (10) #include \ int LB(int *a,int n){ int s=1; for(int i=0;i return s; } void main() {int a[]={1,2,3,4,5,6,7,8}; int b=LB(a,5)+LB(&a[3],3); cout<<”b=”< (11) #include < iostream.h> #include int age; float pay; }; void main() {Worker x; char *t=”liouting”; int d=38; f=493; strcpy(x.name,t) x.age=d;x.pay=f; cout< 13 (12) #include \ class A{ int a; public: A(int aa=0){a=aa;} ~A(){cout<<”Destructor A!”< }; class B:public A{ int b; public: B(int aa=0,int bb=0):A(aa){b=bb;} ~B(){cout<<”Destructor B!”< void main() {B x(5),y(6,7); } (13) #include #include double SD(int a,int b,char op){ double x; switch(op){ case ?+?:x=double(a )+b;break; case ?-?:x=double( a)-b;break; case ?*?:x=double(a)*b;break; case ?/?:if(b)x=double(a)/b;break; else exit(1); default:exit(1); } return x; } void main() {int x=25,y=8; cout< } (14) #include void main() {int a[8]={36,25,48,14,55,40,32,66}; int b1,b2; 14 b1=b2=a[0]; for(i=1;i<8;i++) { if(a[i]>b1){ if(b1>b2) b2=b1; b1=a[i]; } cout< 若将>全改成<,结果如何? (15) #include void WF(int x,int y){ x=x+y; y=x+y; cout<<”sub:”<<”x,y=”< void main() {int x=8,y=15; cout<<”main:”<<”x,y=”< cout<<”main:”<<”x,y=”< cout<<”main:”<<”x,y=”< } (16) #include void LC(int a,int b){ int x=a; a=b; b=x; cout< void main() {int x=10,y=25; LC(x,y); cout< } 若将LC的形参表改为:LC(int &a,int &b)则结果如何?(17) #include #include int age; float pay; 15 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库《C++语言程序设计》综合练习与期末复习题(3)在线全文阅读。
相关推荐: