《C 语言程序设计》阅读程序写结果试题汇总(138 页)Good is good, but better carries it.精益求精,善益求善。阅读程序写结果试题第四章 选择结构 (共 20 道题)1. (于蕾)#include void main( ){ int x,y,t;x=7;y=9;if(xvoid 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=33. (于蕾)#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,55. (王伟)#include int main(){int a,b,c,m;printf("Enter three integers:");scanf("%d%d%d",&a,&b,&c);if(a<=b)m=a;elsem=b;if(c运行结果:m=216. (王伟)#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=D7. (王伟)#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.6000008. (王伟)#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: printf("A\n"); case 8: printf("B\n"); case 7: printf("C\n"); break; case 6: printf("D\n"); break; default: pr...