中国大学MOOC: 以下程序输出的结果是()# include int main(){ int a = 4; switch(a ) { case 0: printf("this is 0\n"); break; case 1: printf("this is 1\n"); break; case 2: printf("this is 2\n"); break; default: printf("this is default\n"); } return 0;
举一反三
- 下列程序的输出结果是_____________ main() { int a=1,b=0; switch(a) { case 1: switch (b) { case 0: printf("**0**"); break; case 1: printf("**1**"); break; } case 2: printf("**2**"); break; } }
- 下面程序的运行结果是 #include<stdio.h> int main() { int a[]= {2,3,5,4},i; for(i=0; i<4; i++) switch(i%2) { case 0: switch(a[i]%2) { case 0: a[i]++; break; case 1: a[i]--; } break; } for(i=0; i<4; i++) printf("%2d",a[i]); printf("\n"); return 0; }
- #include <;stdio.h>;int main(){int x=1,a=0,b=0;switch(x){case 0:b++;break;case 1: a++;case 2: a++;b++;}printf("a=%d,b=%d\n",a,b);return 0;}程序输出结果:
- #include <stdio.h> main() { int c=0,k; for(k=1;k<3;k++) switch(k) { default:c+=k; case 2:c++;break; case 4:c+=2;break; } printf("%d\n",c); }
- 中国大学MOOC: 如下代码片段的输出是什么? int a = 1, b = 0; switch (a) { case 1: switch (b) { case 0: printf (**0**); break; case 1: printf (**1**); break; } case 2: printf (**2**); break; }