以下程序的运行结果是( )#includeint main(){int a=-5,b=1,c=1;int x=0,y=2,z=0;if(c>0)x=x+y;if(a<=0){if(b>0)if(c<=0)y=x-y;}else if(c>0)y=x-y;elsez=y;printf("%d,%d,%d",x,y,z);return 0;}
A. 2,2,0
B. 2,2,2
C. 0,2,0
D. 2,0,2
查看答案
两次运行下面的程序,如果从键盘上分别输入3和2,则输出结果是( )#includeint main(){int x;scanf("%d",&x);if(x++>2)printf("%d",x);elseprintf("%d",x--);return 0;}
A. 4和3
B. 4和2
C. 4和1
D. 3和2
有下面程序,从键盘输入字母H,则输出结果是( )#include int main(){char ch;ch=getchar();switch(ch){case 'H':printf("Hello!\n");case 'G':printf("Good morning!\n");default:printf("Bye_Bye!\n");}return 0;}
A. Hello!
B. Hello!Good morning!
C. Hello!Good morning!Bye_Bye!
D. Hello!Bye_Bye!
有以下程序:#includeint main(){int x=1,y=0;if(!x)y++;else if(x==0)if(x)y+=2;else y+=3;printf("%d\n",y);return 0;}
A. 3
B. 2
C. 1
D. 0
有如下程序:#include int main(){int m=1,a=0,b=0;switch(m){case 0:b++;case 1:a++;case 2:a++;b++;}printf("a=%d,b=%d\n",a,b);return 0;}该程序的输出结果是( )
A. a=2,b=l
B. a=l,b=l
C. a=l,b=0
D. a=2,b=2