资源描述:
《《c语言程序设计》阅读程序写结果试题汇总》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、word格式精心整理版阅读程序写结果试题第四章选择结构(共20道题)1.(于蕾)#includevoidmain(){intx,y,t;x=7;y=9;if(xvoidmain(){intx=1,a=2,b=3;switch(x){case1:a--;break;case2:b++;break;case3:a++;b++;}printf("
2、na=%d,b=%d",a,b);}运行结果:a=1,b=33.(于蕾)#includevoidmain(){charch1='E';if(ch1>='A')范文范例学习指导word格式精心整理版ch1++;elsech1+=32;printf("ch1=%c",ch1);}运行结果:ch1=F4.(于蕾)#includevoidmain(){intx,y,t;x=5;y=3;if(x>y){t=x;x=y;y=t;}printf("%d,%d",x,
3、y);}运行结果:3,55.(王伟)#includeintmain(){inta,b,c,m;printf("Enterthreeintegers:");scanf("%d%d%d",&a,&b,&c);if(a<=b)m=a;elsem=b;if(c运行结果:m=21范文范例学习指导word格式精心整理版6.(王伟)#includeintmain(){charch1=
4、'a',ch2='B',ch3='E';if(ch1>ch2)if(ch2>ch3)ch3++;else--ch3;printf("ch3=%c",ch3);return0;}运行结果:ch3=D7.(王伟)#includeintmain(){floatx,y;scanf("%f",&x);switch((int)x/10){case0:y=1.0;printf("y=%f",y);break;case1:y=2*x+1;printf("y=%f",y);break;c
5、ase2:y=3*x*x+2;printf("y=%f",y);break;default:printf("Nodefinition.");}return0;}输入:15.3<回车>运行结果:y=31.600000范文范例学习指导word格式精心整理版8.(王伟)#includeintmain(){charch1='A',ch2='B';switch(ch1){case'A':switch(ch2){case'B':printf("Good!");break;case'
6、A':printf("Better!");break;}case'B':printf("Best!");break;}return0;}运行结果:Good!Best!9.(王锋)#includevoidmain(){floatscore;score=100;if(score<60)printf("E");elseswitch((int)score/10){case10:case9:printf("A");case8:printf("B");case7:print
7、f("C");break;case6:printf("D");break;default:printf("Error");}}运行结果:范文范例学习指导word格式精心整理版ABC10.(王锋)#includevoidmain(){inti=0,a=2;if(i==0)printf(“**”);elseprintf(“$$”);printf(“*”);}运行结果:***11.(王锋)#includevoidmain(){intm=10,n=0,p=4,
8、q=20;if(m)if(n)q=15-m;elseq=25+m;elseif(p)q=q+p;printf(“q=%d”,q);}运行结果:q=3512.(王锋)#includevoidmain(){inta=1,b=0;switch(a)范文范例学习指导word格式精心整理版{case1:switch(b){case0:printf(“**0**”);break;case1:printf(“**1**”);break;}case2:print