举一反三
- 4-12、设有程序段: switch(grade) { case ‘A’: printf(“85-100\\”); case ‘B’: printf(“70-84\\”); case ‘C’: printf(“60-69\\”); case ‘D’: printf(“<60\\”); default: printf(“error!\n”); } 若grade的值为‘C’,则输出结果是________。
- 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,请问运行结果为:
- 若输入B,以下程序的运行结果为()。main(){chargrade;scanf("%c",&grade);switch(grade){case'A':printf(">=85");case'B':case'C':printf(">=60");case'D':printf("<60");default:printf("error");}}(5.0分)
- 下面程序段的输出结果是______。 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"); }
- 中国大学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;
内容
- 0
若a,b均是整型变量,正确的switch语句是( )。 A: switch(a){case 1.0: printf(“i\n”);case 2: printf(“you\n”); ”);} B: switch(a){case b: printf(“i\n”);case 1: printf(“you\n”);} C: switch(a+b){case 1: printf(“i\n”);case 2*a: printf(“you\n”);} D: switch(a+b){case 1: printf(“i\n”);case 2: printf(“you\n”);}
- 1
若输入B,以下程序的运行结果为。 main() {char grade;scanf("%c",&grade); switch(grade) {case'A':printf(">=85."); case'B': case'C':printf(">=60."); case'D':printf("<60."); default:printf("error."); } }
- 2
若有以下定义,则正确的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");
- 3
若有float x; int a,b; ,下面四条switch语句中正确的有( )条。 switch(x) { case x=1.0: printf(“Y”); case x=2.0: printf(“N”); } switch(a) { case a=1: printf(“Y”); case a=2: printf(“N”); } switch(b) { case b==1: printf(“Y”); case b==2: printf(“N”); } switch(x) { case 1.0: printf(“Y”); case 2.0: printf(“N”); }
- 4
智慧职教:将下列程序补充完整,实现成绩等级输出。#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