智慧职教:将下列程序补充完整,实现成绩等级输出。#include
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
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