下面程序的运行结果是______。#include int main(){ int a[3][3]={1,2,3,4,5,6,7,8,9},i;for(i=0;i<=2;i++) printf("%d ",a[i][2-i]); }
A. 3 5 7
B. 3 6 9
C. 1 5 9
D. 1 4 7
查看答案
若有定义:float x=1.5;int a=1,b=3,c=2; ,则正确的switch语句是______。
A. switch(x)//()里为整型,字符,枚举{ case 1.0: printf("*\n");case 2.0: printf("**\n");}
B. switch(int(x)){ case 1: printf("*\n");case 2: printf("**\n");}
C. switch(a+b){ case 1: printf("*\n"); case 2+1: printf("**\n");}
D. switch(a+b){ case 1: printf("*\n");case c: printf("**\n");}
下面程序段的输出结果是______。int n='c';switch(n++) // n先用,后自增(n=’c’)。{default: printf("error"); break;case 'a':case 'A':case 'b':case 'B': printf("good"); break;case 'c':case 'C': printf("pass");case 'd':case 'D': printf("warn"); }
A. passwarn
B. passerror
C. goodpasswarn
D. pass
下述程序的输出结果是_______。#inlude int main(){ int x=1,y=0,a=0,b=0;switch(x){ case 1: switch(y){ case 0: a++; break;case 1: b++;break; }case 2: a++;b++;break;case 3: a++;b++;}printf("\na=%d,b=%d",a,b);return 0; }
A. a=1,b=0
B. a=2,b=1
C. a=1,b=1
D. a=2,b=2
以下程序运行后的输出结果是_______。#inlude int main(){ int a=15,b=21,m=0;switch(a%3) //15%3=0{ case 0: m++; break; // 执行后,退出第一层。case 1: m++;switch(b%2) //第二层,未执行{ default: m++;case 0: m++; break; }}printf("%d\n",m);return 0; }
A. 1
B. 2
C. 3
D. 4