运行以下程序后,如果从键盘上输入china#,则输出结果是什么?#include main( ) { int v1=0,v2=0; char ch ; while ((ch=getchar())!='#') switch (ch ) { case 'a':case 'h':default:v1++; case '0':v2++; } printf(""%d,%d\n"",v1,v2);" case 'h'

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 02:15:15
运行以下程序后,如果从键盘上输入china#,则输出结果是什么?#include main( ) { int v1=0,v2=0; char ch ; while ((ch=getchar())!='#') switch (ch ) { case 'a':case 'h':default:v1++; case '0':v2++; } printf(

运行以下程序后,如果从键盘上输入china#,则输出结果是什么?#include main( ) { int v1=0,v2=0; char ch ; while ((ch=getchar())!='#') switch (ch ) { case 'a':case 'h':default:v1++; case '0':v2++; } printf(""%d,%d\n"",v1,v2);" case 'h'
运行以下程序后,如果从键盘上输入china#,则输出结果是什么?
#include
main( )
{ int v1=0,v2=0;
char ch ;
while ((ch=getchar())!='#')
switch (ch )
{ case 'a':
case 'h':
default:v1++;
case '0':v2++;
}
printf(""%d,%d\n"",v1,v2);"
case 'h':
default:v1++;
case'o':v2++;}
printf("%d,%d/n",v1,v2);}
我得5,0 5 麻烦给出具体过程

运行以下程序后,如果从键盘上输入china#,则输出结果是什么?#include main( ) { int v1=0,v2=0; char ch ; while ((ch=getchar())!='#') switch (ch ) { case 'a':case 'h':default:v1++; case '0':v2++; } printf(""%d,%d\n"",v1,v2);" case 'h'
由于下面switch中case语句没有break.所以每一个case语句都会执行.那么v1和v2的结果就是一样的.结果5,5
while ((ch=getchar())!='#')
switch (ch )
{ case 'a':
case 'h':
default: v1++;
case '0':v2++;
}