如果month=4,下面代码的输出结果是( ) int days=0; switch(month) { case 2: days=28; break; case 4: case 6: case 9: case 11: days=30; break; default: days=31; break; } Console.WriteLine(days);
举一反三
- 当month 等于6时,下面代码的输出结果是()。 int days = 0; switch (month) { case 2: days = 28; break; case 4: case 6: case 9: case 11: days = 30; break; default: days = 31; break; }
- 以下程序运行后的输出结果是______。 void main() { int s=0,k; for(k=7; k>=0; k--) { switch(k) { case 1: case 4: case 7: s++; break; case 2: case 3: case 6: break; case 0: case 5: s+=2; break; } } printf("s=%d\n",s); }
- 中国大学MOOC: 以下程序输出的结果是()# include <stdio.h>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; } }
- 若有定义语句int a, b;double x;则下列选项中正确的是( ). A: switch(x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } B: switch((int)x/2.0) { case 1: b++; break; case 0: a++; break; default : a++; b++; } C: switch((int)x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } D: switch((int)(x)%2) { case 0.0: a++; break; case 1.0: b++; break; default : a++; b++; }