1、C+程序设计模拟试题一、选择和填空:1.C+程序的基本单位是( )A. 程序行 B. 语句 C. 函数 D. 字符2.假设所有变量均为整型.则表达式(a=4,b=6,a+,a+b)的值是_3.下列程序段运行后 x 的值是:_a=b=c=0;x=35;if (!a) x-;else if (b); if ( c) x=3;else x=5;4. 若有定义: float w; int a, b; 则合法的 switch 语句是A. switch(w) case 1.0: cout0; y-) if(y%3=0) coutvoid main()char ch25=“6937”, “8254”, *p
2、2;int i, j, s=0;for (i=0; i0; j+=2)s=10*s+pij-0;coutsub1(char a, char b)char c; c=a; a=b; b=c;sub2(char *a, char b)char c; c=*a; *a=b; b=c;sub3(char *a, char *b)char c; c=*a; *a=*b; *b=c;void main() char a,b;a=A; b=B; sub3( coutdata.a D. p.data19.以下程序的输出结果是 _ include fun(int n,int *s) int f1,f2;if(n
3、=1|n=2) *s=1; else fun(n-1, fun(n-2,*s=f1+f2; void main() int x; fun(6, coutmain() char *s=“12134211“; int v4=0,0,0,0,k,i;for(k=0;sk;k+) switch(sk) case 1:i=0;case 2:i=1;case 3:i=2;case 4:i=3;vi+;for(k=0;k=A switch(n) case 1:case 2: cout 8;y=+i)coutmain() int i, x33=1,2,3,4,5,6,7,8,9;for (i=0; i3; i+) coutxi2-i”,”;