关于C语言的选择题?//
来源:百度知道 编辑:UC知道 时间:2024/09/19 16:10:17
x=0; y=2; z=3;
switch(x)
{ case 0: switch(y==2)
{ case 1: printf("*"); break;
case 2: printf("%"); break;
}
case 1: switch(z)
{ case 1: printf("$");
case 2: printf("*"); break;
default : printf("#");
}
}
的输出结果是???
为什么还会输出 # 号啊
switch(x)
{ case 0: switch(y==2)
{ case 1: printf("*"); break;
case 2: printf("%"); break;
}
case 1: switch(z)
{ case 1: printf("$");
case 2: printf("*"); break;
default : printf("#");
}
}
的输出结果是???
为什么还会输出 # 号啊
我帮你看了一下
结果是
*%#
为什么还会输出 # 号啊~~!
因为
case 1: switch(z)
{ case 1: printf("$");
case 2: printf("*"); break;
default : printf("#");
}
z等于3,case中没有和他匹配的,所以就会执行default