若运行以下程序时,从键盘输入2473<回车>,则下面程序的运行结果是()。#includemain(){intc;while((c=getchar())!=‘
’)switch(c-‘2’){case0:case1:putchar(c+4);case2:putchar(c+4);break;case3:putchar(c+3);default:putchar(c+2);break;}printf(“
”);}
’)switch(c-‘2’){case0:case1:putchar(c+4);case2:putchar(c+4);break;case3:putchar(c+3);default:putchar(c+2);break;}printf(“
”);}
举一反三
- 以下程序运行后的输出结果是main(){ int c=0,k;for(k=1;k<3;k++)switch(k){ default:c+=k;case 2:c++;break;case 4:c+=2;break; }printf("%d ",c);}
- 以下程序运行后的输出结果是______。 void main() { int s=0,k; for(k=7; k>=0; k--) { switch(k) { case 1: case 4: case 7: s++; break; case 2: case 3: case 6: break; case 0: case 5: s+=2; break; } } printf("s=%d\n",s); }
- 1、main(){ int x=2,y;switch(x){ case 1: y=x ; break;case 2: y=-x ;case 3: y=x*3 ; break;case 4: y=4*x;}printf(“%d\n”,y);}程序运行结果:__________________
- 中国大学MOOC: 以下程序输出的结果是()# include <stdio.h>int main(){ int a = 4; switch(a ) { case 0: printf("this is 0\n"); break; case 1: printf("this is 1\n"); break; case 2: printf("this is 2\n"); break; default: printf("this is default\n"); } return 0;
- 下列程序的输出结果是_____________ main() { int a=1,b=0; switch(a) { case 1: switch (b) { case 0: printf("**0**"); break; case 1: printf("**1**"); break; } case 2: printf("**2**"); break; } }