下列程序的输入结果是 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这条我一点都不懂,

问题描述:

下列程序的输入结果是 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
这条我一点都不懂,

#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
}