c++复习题及答案

loading 分享 2026-8-10 下载文档

return 0;

答案:8 3.

#in clude using n amespace std; mai n() {int i,j,x=O; for(i=0;i<2;i++) {x++;

for(j=0;j<=3;j++) {if (j%2) con ti nue; x++; } x++; }

cout<< “x=” <

4.

#in clude using n amespace std; mai n() {i nt i;

for(i=1;i<=5;i++)

{if(i %2) cout<< “ * ”; else con ti nue; cout<< “#\; }

cout<< \n” ; }

答案:*#*#*#$ 5.

#in clude using n amespace std; void mai n() { int I,j,a=0; for(l=0;l<2;l++) { for(j=0;j<4;j++) { if(j%2) break;

a++; } a++;

cout<

答案:4 6.

运行以下程序时,从键盘键入 #in clude using n amespace std; void mai n() {char c;

while((c=getchar())!=?) putchar(++c); } 答案:sjhiu 7.

#in clude void mai n() {i nt I;

for(l=1;l<=5;l++) switch(l%2)

{case 0:I++; cout<<\case 1:I+=2; cout<<\default: cout<<\} } 答案:* # 8.

#i nclude using n amespace std; int a=5; int mai n () { int a=10, b=20; { int a=0,b=0;

for (i nt i=1; i<6; i++) {a+=i ; b+=a;} }

cout <

20

right?请给出回车后运行的结果。

#in clude using n amespace std; int k=1;

void f(i nt m) {m+=k; k+=m;

{char k='B'; cout<< k - 'A' <<'\\n'; }

cout<

int mai n() {int i=4; f(i);

cout<

程序的输出第一行是 1 ,第二行是 5 , 6 ,第三行是 4 , 6 10. # in elude

# in elude int main()

{ char a[5]={\

char p1, p2; p仁 p2=a[0]; for (int i=0; i<5; i++)

{ if (strcmp(a[i],p1)>0) p 1= a[i];

if (strcmp(a[i],p2)<0) p2=a[i];

}

cout <

答案:worker cadre

11. #in clude

using n amespace std;

in t m[3][3]={ {1}, {2}, {3} }, n[3][3]={ 1,2, 3 }; int mai n()

{ cout<

程序的输出第一行是 上 ______ ,第二行是_0 _______ 。 12. #in clude

using n amespace std; void f (int s[]) {static int j;

do{s[j]+=s[j+1]; } while (++j<2); }

int mai n()


c++复习题及答案.doc 将本文的Word文档下载到电脑
搜索更多关于: c++复习题及答案 的文档
相关推荐
相关阅读