这个输出为什么是7呀
main(){
int k=5,n=0;
while(k>0)
{
switch(k)
{
default:break;
case 1: n += k;
case 2:
case 3: n += k;
}
k--;
}
printf("%d\n",n);
}
k = 5 : break
k = 4 : break
k = 3 : n += k --> n = 0 + 3 = 3
k = 2 : n += k --> n = 3 + 2 = 5
k = 1 : n += k , n += k --> n = 5 + 1 + 1 = 7 jackz007 发表于 2022-1-17 00:41
谢谢
页:
[1]