问题 填空题

下列程序的输出结果为 【12】 。# include <iostream, h>void Func(char ch){ switch (ch). { case ’A’: case ’a’ cout<<"优秀"<<end1; case ’B’: case ’b’: cout<<"良好"<<end1; break; case ’C’: case ’c’: cout<<"及格" <<end1 break; default cout<<"不及格"<<end1; }}void main(){ char ch1 =’b’ Fune(chl); Func(’A’);}

答案

参考答案:良好 优秀 良好

解析: 本题主要考察switch语句中break语句的使用。由于case A和 case B之间没有break语句,导致在输出“优秀”之后顺序执行并输出了“良好”,这与原来的设计思路是不符的。

单项选择题 A型题
单项选择题