单选题有以下程序:#includemain(){ char *s=120119110; int n0,n1,n2,nn,i; n0=n1=n2=nn=i=0; do {  switch(s[i++])  {   default:nn++;   case '0':n0++;   case '1':n1++;   case '2':n2++;  } }while(s[i]); printf(n0=%d,n1=%d,n2=%d,nn=%d,n0,n1,n2,nn);}程序的运行结果是(  )。An0=3,n1=8,n2=9,nn=1Bn0=2,n1=5,n2=1,nn=1Cn0=2,n1=7,n2=10,nn=1Dn0=4,n1=8,n2=9,nn=1

单选题
有以下程序:#includemain(){ char *s=120119110; int n0,n1,n2,nn,i; n0=n1=n2=nn=i=0; do {  switch(s[i++])  {   default:nn++;   case '0':n0++;   case '1':n1++;   case '2':n2++;  } }while(s[i]); printf(n0=%d,n1=%d,n2=%d,nn=%d,n0,n1,n2,nn);}程序的运行结果是(  )。
A

n0=3,n1=8,n2=9,nn=1

B

n0=2,n1=5,n2=1,nn=1

C

n0=2,n1=7,n2=10,nn=1

D

n0=4,n1=8,n2=9,nn=1


参考解析

解析:
本题执行过程为:s[0]='1',匹配case'1',n1=1,n2=1;s[1]='2',匹配case'2',n2=2;s[2]='0',匹配case'0',n0=1,n1=2,n2=3;s[3]='1',匹配case'1',n1=3,n2=4;s[4]='1',匹配case'1',n1=4,n2=5;s[5]='9',匹配default,nn=1,n0=2,n1=5,n2=6;s[6]='1',匹配case'1',n1=6,n2=7;s[7]='1',匹配case'1',n1=7,n2=8;s[8]='0',匹配ease'0',n0=3,n1=8,n2=9;s[9]='\0',退出循环。输出n0,n1,n2,nn为3,8,9,1,答案选择A选项。

相关考题:

设有如下程序:main(){int n1,n2;scanf("%d",n2);while(n2!=0){ n1=n2%10;n2=n2/10;printf("%d",n1);}}程序运行后,如果从键盘上输入1298,则输出结果为【】。

有以下程序inclUdevoidfun(int*s,intn1,intn2){inti,j,t;i=n1;j=n2;while(i 有以下程序 #inclUde <stdio.h> void fun(int *s,int n1,int n2) { int i,j,t; i=n1; j=n2; while(i<j) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4A.0987654321B.4321098765C.5678901234D.0987651234

【程序】SET TALK OFFN=325X=“ABCDEFGHIJ”Y=“甲乙丙丁戊已.”NC=ALLTRIM(STR(N,6))L=LEN(NC)N2=2*L-1NN="K=1DO WHILE K<=LN1=INT(VAL(SUBSTR(NC,K,1))* 2+1)NN=NN+SUBSTR(X,N1,1)NN=NN+SUBSTR(Y,N2,2)? N1,N2,NNN2=N2-2K=K+1ENDDO? KSET TALK ON第一次输出结果为 ______。A.7 4G 甲B.7 5G乙C.7 5G 丙D.7 4G乙

下列程序段的时间复杂度为()。i=0,s=0;while(sn){s=s+i;i++;}A、O(n1/2)B、O(n1/3)C、O(n)D、O(n2)

下列程序的输出结果是()。includemain(){int a=0,i; for(i=1;i 下列程序的输出结果是( )。 #include<stdio.h> main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=1; case 1: case 2:a+=2; default:a+=3; } printf("%d",A) ; }A.19B.18C.6D.8

下列程序是死循环的是A.for(;;);B.int s=36; while(S)--S;C.int m=10; do { m- - }while(m0);D.int n=5; while(n1) { n- -; if(n0)break; }

已知C源程序如下: include include void reverse(char S[]){ int C,i,J; f 已知C源程序如下:include<stdio. h>include<string. h>void reverse(char S[]){int C,i,J;for(i=0,j=strlen(s)-1;i<j;i++,j++){c=s[i];s[i]=s[j];s[j]=c;}}void getHex(int number,char s[]){int I;i=0;while(number>0){if(number%16<10)s[i++]=number%16+'0';elseswitch(number%16){case 10:s[i++]='A';break;case 11:s[i++]='B';break;case 12:s[i++]='C';break;case 13:s[i++]='D';break;case 14:s[i++]='E';break;case 15:s[i++]='F';break;default:printf("Error");break;}number/=16;}s[i]:'\o';reverse(s);}int main(){unsigned int number;int i=0:char s[50];printf("%s","please input number;\n");scanf("%d",&number):getHex(number,s);i=0;while(s[i])printf("%c",s[i++]);return 0;}画出程序中所有函数的控制流程图。

有下列程序: include void fun(int * s,int n1,int n2) { int i,j, 有下列程序: #include <stdio.h> void fun(int * s,int n1,int n2) { int i,j,t; i=n1;j=n2; while(i<j){t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4,9);fun(a,0,9); for(k=0;k<10;k++)printf("%d",a[k]);printf("\n"); } 程序的运行结果是( )。A.987654321B.4321098765C.5678901234D.987651234

有下列程序: #includestdi0.h voidfun(int*S,intn1,intn2) { inti,j,t; i=n1;j=n2 while(ij){t=s[i];s[i]=s[j];s[j]=t;i++;j --;} } voidmain( ) { inta[10]={1,2,3,4,5,6,7,8,9,0),k; fun(a,0,3);fun(a,4,9);fun(a,0,9); for(k=0;k10;k++)printf(”%d”,a[k]);printf ("\n"); } 程序的运行结果是( )。A.0987654321B.4321098765C.5678901234D.0987651234

以下程序的输出结果是()。includemain(){int a,i;a=0; for(i=1;i 以下程序的输出结果是( )。 #include <stdio.h> main() { int a,i;a=0; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=2; case 1: case 2:a+=3; default:a+=5; } } printf("%d\n",a); }A.31B.13C.10D.20

有以下程序includevoid fun(float* p1,int n1,float,*p2,int n2,float* s){ int i;s=( 有以下程序 #include<stdio.h> void fun(float * p1,int n1,float,*p2,int n2,float * s) { int i; s=(float *)calloc(1,sizeof(float)); *s=0; for(i=0;i<n1;i++) *s+=*p1++; for(i=0;i<n2;i++) *s+=*p2++; } main() { float a[2]={1.1,2.2},b[3]={10.0,20.0,30.0),*s=a; fun(a,2,b,3,s); printf("%f\n",*s); } 上面程序的输出结果是( )A.60B.3.3C.63.3D.1.1

有以下程序: include main() {char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1 有以下程序:include <stdio.h>main(){ char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1=ch1-'0'; n2=n1*10+(ch2-'0');printf("%d\n",n2);}程序运行时输入:12<回车>,执行后的输出结果是【 】。

有以下程序#include stdio.hvoid fun(int *s,int n1,int n2){ int i,j,t;i=n1; j=n2;while(ij) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;}}main(){ int a[10]={1,2,3,4,5,6,7,8,9,0},k;fun(a,0,3); fun(a,4,9); fun(a,0,9);for(k=0;kl0;k++)printf("%d",a[k]); printf("\n");}程序的运行结果是A.0987654321B.4321098765C.5678901234D.0987651234

有以下程序includevoidfun(int*s,intn1,intn2){inti,j,t; i=n1j=n2; while(i 有以下程序 #include <stdio.h> void fun(int *s,int n1,int n2) { int i,j,t; i=n1 j=n2; while(i<j) {t=s[i];s[i]=s[j];s[j]=t;i++;j--;} } main() { int a[10]={1,2,3,4,5,6,7,8,9,0},k; fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k<10;k++)printf("%d",a[k]); printf("\n"); } 程序的运行结果是A.987654321B.4321098765C.5678901234D.987651234

以下程序的输出结果是( )。main(){ int i; for(i=0;i3;i++) switch(i) { case 0:printf(3;i++)switch(i){ case 0:printf(%d,i);case 2:printf(%d,i);default:printf(%d,i); }}A.000102B.000020C.000122D.000111

设普通对称式圆锥齿轮差速器壳的转速为n0,左右两半轴的转速分别为n1、n2,则汽车转弯时有()A、n1=n2=n0B、n1=n2=2n0C、n1=n2=0.5n0D、n1+n2=2n0

设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()。A、n1+n2=n0B、n1+n2=2n0C、n1+n2=1/2n0D、n1=n2=n0

对任何一棵二叉树,若n0,n1,n2分别是度为0,1,2的结点的个数,则n0=()。

肺癌国际TNM分期中的Ⅲa期是指()A、T2 N1 M0B、T3 N0 M0C、T2 N2 M0D、T4 N0 M0E、T4 N1 M0

设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()A、n1+n2=n0B、n1+n2=2nC、n1+n2=1/2n0D、n1=n2=n0

设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()。A、n1+n2=n0B、n1+n2=2n0C、n1=n2=n0

填空题对任何一棵二叉树,若n0,n1,n2分别是度为0,1,2的结点的个数,则n0=()。

单选题肺癌国际TNM分期中的Ⅲa期是指()AT2 N1 M0BT3 N0 M0CT2 N2 M0DT4 N0 M0ET4 N1 M0

单选题有以下程序: #include voidfun(int*s,intn1,intn2) {  inti,j,t;  i=n1;  j=n2;  while(i  {   t=s[i];   s[i]=s[j];   s[j]=t;   i++;   j--;  } } main() {  inta[10]={1,2,3,4,5,6,7,8,9,0},k;  fun(a,0,3);  fun(a,4,9);  fun(a,0,9);  for(k=0;k   printf("%d",a[k]);  printf(""); } 程序运行的结果是(  )。A0987654321B4321098765C5678901234D0987651234

单选题设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()。An1+n2=n0Bn1+n2=2n0Cn1+n2=1/2n0Dn1=n2=n0

单选题设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()An1+n2=n0Bn1+n2=2nCn1+n2=1/2n0Dn1=n2=n0

单选题设对称式锥齿轮差速器壳的转速为n0,左、右两侧半轴齿轮的转速分别为n1和n2,则有()。An1+n2=n0Bn1+n2=2n0Cn1=n2=n0