> 其他 >
下列程序的输入结果是 main() {int x=1,a=0,b=0; switch(x){case 0:b++; case 1:a++; case 2:a++;b++; }
(接上面)printf("%d,%d\n",a,b);
}
1
这条我一点都不懂,
人气:338 ℃ 时间:2020-02-05 12:00:52
解答
#include
void main()
{
int x=1,a=0,b=0;
switch(x)//x=1;所以跳到case 1
{
case 0:b++;
case 1:a++; //从这里开始,满足条件:a++.a=1 没有break;语句来跳出继续往下
case 2:a++;b++;//继续执行:执行a++,b++.a=2,b=1 程序结束
}
printf("%d,%d\n",a,b);//所以输出 2,1
}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版