以下程序的运行结果是【 】。 main( ) {int a=2,b=7,c=5; switch(a>O) {case 1:switch(b<0) {Case 1:printf("@");break; Case 2:printf("!");break; } Case 0:switch(c==5) {Case 0:printf("*");break; Case 1:prinff("#");break; case 2:printf("$");break; } default:printf("&"); } printf("\n"); }

以下程序的运行结果是 【9】 。 main( ) { int a=2,b=7,c=5; switch(a>0) { case 1: switch (b<0) { case 1:printf("@"); break; case 2:pnntf("!"); break; } case 0: switch (c==5) { case 0:pnntf("*"); break; case 1:printf("#"); break; case 2:printf("$"); break; } default: printf("&"); } printf("/n"); }

以下程序的运行结果是______。 main( ) (int a=2,b=7,c=5; switch(a>0) {case 1:switch(b<0) {case 1:switch("@");break; case 2:printf("!");break; } case 0:switch(c==5) {case 0:printf("*");break; case 1:printf("#");break; case 2:printf("$");break; } default:printf ("&"); } printf("/n"); }

填空题 请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include #include main( ) { int i,b[11]; char *str="ab123456789cde090"; char *p=str; clrscr( ); printf("*** the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) { switch(【1】) { case ’’0’’:b[0]++;break; case ’’1’’:b[1]++;break; case ’’2’’:b[2]++;break; case ’’3’’:b[3]++;break; case ’’4’’:b[4]++;break; case ’’5’’:b[5]++;break; case ’’6’’:b[6]++;break; case ’’7’’:b[7]++;break; case ’’8’’:b[8]++;break; case ’’9’’:b[9]++;break; 【2】 } 【3】 } printf("****** the result ********/n"); for(i=0;i<10;i++) printf("/n%d:%d",i,b[i]); printf("/nother charactor:%d",b[i]); }

【1】*p 【2】default: b[10]++; 【3】p++;

请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #include <conio.h> main( ) { int i,b[11]; char *str="abl23456789cde090"; char *p=str; clrscr( ); printf("***the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) { switch( 【1】 ) { case ’0’:b[0]++;break; case ’1’:b[1]++;break; case ’2’:b[2]++;break; case ’3’:b[3]++;break; case ’4’:b[4]++;break; case ’5’:b[5]++;break; case ’6’:b[6]++;break; case ’7’:b[7]++;break; case ’8’:b[8]++;break; case ’9’:b[9]++;break; 【2】 } 【3】 } printf("****** the result ********/n"); for(i=0;i<10;i++) printf("/n%d:%d",i,b[i]); printf("/nother charactor:%d",b[i]); }

【1】*p 【2】default:b[10]++; 【3】p++;

以下程序的运行结果是【 】。 main( ) {int a=2,b=7,c=5; switch(a>O) {case 1:switch(b<0) {Case 1:printf("@");break; Case 2:printf("!");break; } Case 0:switch(c==5) {Case 0:printf("*");break; Case 1:prinff("#");break; case 2:printf("$");break; } default:printf("&"); } printf("\n"); }

填空题 请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。 例如:当str1=“ab123456789cde090”时,结果为: 0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include #include main( ) { int i,b[11]; char *str="ab123456789cde090"; char *p=str; clrscr( ); printf("*** the origial data ***/n"); puts(str); for(i=0;i<11;i++) b[i]=0; while(*p) { switch(【1】) { case ’’0’’:b[0]++;break; case ’’1’’:b[1]++;break; case ’’2’’:b[2]++;break; case ’’3’’:b[3]++;break; case ’’4’’:b[4]++;break; case ’’5’’:b[5]++;break; case ’’6’’:b[6]++;break; case ’’7’’:b[7]++;break; case ’’8’’:b[8]++;break; case ’’9’’:b[9]++;break; 【2】 } 【3】 } printf("****** the result ********/n"); for(i=0;i<10;i++) printf("/n%d:%d",i,b[i]); printf("/nother charactor:%d",b[i]); }

【1】*p 【2】default: b[10]++; 【3】p++;

微信扫码获取答案解析
下载APP查看答案解析