voidmain(){ int score; printf("请输入课程成绩(整数):"); scanf("%d",_____________); if(score>100||score<0) printf("输入错误!\n"); ___________ switch((int)_____________) { case10: case 9: printf("优秀!\n");_______________; case 8: printf("良好!\n");break; case 7: printf("中等!\n");break; case 6: printf("及格!\n");break; ___________: printf("不及格!\n"); }}5a0d99e305fecac500efc6ceb6743312198ebb4c0b8ac8d45ef1b9c6a80adc39a7be2ada98413e6c26c75ec4895239a23c5293ff6edff209abd64c9363088bbdf81f9a20a32b1b046de18a8f04c74749
举一反三
- 中国大学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;
- switch(a){ case 1:printf(“Monday\n"); case 2:printf("Tuesday\n"); case 3:printf(“Wednesday\n"); case 4:printf("Thursday\n"); case 5:printf("Friday\n");break; case 6:printf("Saturday\n"); case 7:printf("Sunday\n"); } 若a的值为6,请问运行结果为:
- 运行以下程序段,并输入1,则输出结果是( )。 int x; printf("请输入一个0-2的整数:"); scanf("%d",&x); switch(x) { case 0:printf("输入0。\n"); case 1:printf("输入1。\n"); case 2:printf("输入2。\n"); default:printf("输入错误! \n"); }
- 下面程序段的输出结果是______。 int n= int n='c'; switch(n++) {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"); }
- 下面程序段执行后的输出结果是( )。int main(){int x=3,y=6;switch(x) {case 1:y++;case 2:++y;break;default:y++;}printf("%d\n", y);return 0;} A: 6 B: 7 C: 8 D: 9
内容
- 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; } }
- 1
以下程序运行后的输出结果是______。 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); }
- 2
#include main()_ { char grade=’C’; switch(grade) { case ‘A’: printf(“90-100\n”); case ‘B’: printf(“80-90\n”); case ‘C’: printf(“70-80\n”); case ‘D’: printf(“60-70\n”); break; case ‘E’: printf(“<60\n”); default : printf(“error!\n”); } } 运行结果为( )
- 3
执行语句序列 int n; scanf("%d",&n); switch(n) { case 1: printf("%c ",'1'); case 3: case 4: printf("%c ",'2');; break; default: printf("%c ",'3'); } 时,若键盘输入1,则屏幕显示【 】
- 4
若有以下定义,则正确的switch语句是______。float x;int a,b; A: switch(x) B: case 1.0:printf("*\n"); C: csse 2.0:printf("**\n"); D: switch(x) E: case 1,2:printf("*\n"); F: case 3:printf("**\n"); G: switch(a+b) H: case 1:printf("\n"); I: case 1+2:printf("**\n"); J: switch(a+b); K: case 1:printf("*\n"); L: case 2:printf("**\n");