阅读程序写结果试题 第四章 选择结构 (共2 0 道题) 1. (于蕾) #include void main( ) { int x,y,t; x=7;y=9; if(x void main( ) { int x=1,a=2,b=3; switch(x) { case 1: a--; break; case 2: b++; break; case 3: a++;b++; } printf("\na=%d,b=%d\n",a,b); } 运行结果: a=1,b=3 3. (于蕾) #include void main( ) { char ch1 = 'E'; if(ch1 >= 'A') ch1++; else ch1+=32; printf("ch1 = %c\n", ch1); } 运行结果: ch1= F 4. (于蕾) #include void main( ) { int x,y,t; x=5;y=3; if(x>y) { t=x;x=y;y=t;} printf("%d,%d\n" , x,y ); } 运行结果: 3,5 5. (王伟) #include int main() { int a,b,c,m; printf("Enter three integers:"); scanf("%d%d%d",&a,&b,&c); if(a<=b) m=a; else m=b; if(c 运行结果: m=21 6. (王伟) #include int main() { char ch1='a',ch2='B',ch3='E'; if(ch1>ch2) if(ch2>ch3) ch3++; else --ch3; printf("ch3=%c\n",ch3); return 0; } 运行结果: ch3=D 7. (王伟) #include int main() { float x,y; scanf("%f",&x); switch((int)x/10) { case 0: y=1.0; printf("y=%f\n",y);break; case 1: y=2*x+1; printf("y=%f\n",y);break; case 2: y=3*x*x+2; printf("y=%f\n",y);break; default: printf("No definition.\n"); } return 0; } 输入:15.3<回车> 运行结果: y=31.600000 8. (王伟) #include int main() { char ch1='A',ch2='B'; switch(ch1) { case 'A': switch(ch2) { case 'B': printf("Good!\n");break; case 'A': printf("Better!\n");break; } case 'B': printf("Best!\n"); break; } return 0; } 运行结果: Good! Best! 9. (王锋) #include void main() { float score; score = 100; if (score<60) printf("E\n"); else switch( ( int ) score / 10 ) { case 10: case 9:...