欢迎来到天天文库
浏览记录
ID:40933483
大小:101.50 KB
页数:26页
时间:2019-08-11
《实验教程编程答案!!!! - 副本》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验二输入/输出与顺序结构4.编程题⑵输入学生的语文、数学、英语、物理4门课程的成绩,计算该学生的总成绩和平均成绩并输出。#includevoidmain(){doubleeng,chin,math,phy,sum,aver;cout<<"pleaseinput4scores:";cin>>eng>>chin>>math>>phy;//输入成绩sum=eng+chin+math+phy;//计算总成绩aver=sum/4;//计算平均分cout<<"Sum="<2、voidmain(){charc1,c2;cout<<"Pleaseinputanupperletter:";cin>>c1;c2=c1+32;cout<<"c1="<3、ostream.h>voidmain(){charx,max;cout<<"Pleaseinputthreecharacterss:";cin>>x;max=x;cin>>x;26if(x>max)max=x;cin>>x;if(x>max)max=x;cout<<"max="<0)-1(x<0)【源程序】#includevoidmain(){intx,y;cout<<"Pleaseinputx=";4、cin>>x;if(x>0)y=1;elseif(x==0)y=0;elsey=-1;cout<<"y="<5、00000元时,超过50000元部分按3.5%计算奖金;当L超过100000元时,超过100000元部分按4%计算奖金。由键盘输入L的值,编程计算相应的奖金并输出。【源程序】#includevoidmain(){doubleL,S;cout<<"pleaseinputL=";cin>>L;26if(L<5000)S=L*0.015;elseif(L<10000)S=75+(L-5000)*0.02;elseif(L<20000)S=175+(L-10000)*0.025;6、elseif(L<50000)S=175+250+(L-20000)*0.03;elseif(L<100000)S=175+250+900+(L-50000)*0.035;elseS=175+250+900+1750+(L-100000)*0.04;cout<<"S="<voi7、dmain(){intage;cout<<"Pleaseinputage:";cin>>age;switch(age/10){case0:cout<<"A--儿童";break;case1:cout<<"B--少年";break;case2:cout<<"C--青年";break;case3:case4:cout<<"D--中年";break;default:cout<<"E--老年";break;}}实验四循环结构程序设计4.编程题⑴输入n,求1+2+3+……+n的和。#i8、ncludevoidmain(){26inti,n;doublesum=0;cin>>n;for(i=1;i<=n;i++)sum+=i;cout<<"1+2+3+...+"<voidmain(){charch,maxchar;cout<<"pleaseinputtencharacter:";cin>>ch;maxchar=
2、voidmain(){charc1,c2;cout<<"Pleaseinputanupperletter:";cin>>c1;c2=c1+32;cout<<"c1="<3、ostream.h>voidmain(){charx,max;cout<<"Pleaseinputthreecharacterss:";cin>>x;max=x;cin>>x;26if(x>max)max=x;cin>>x;if(x>max)max=x;cout<<"max="<0)-1(x<0)【源程序】#includevoidmain(){intx,y;cout<<"Pleaseinputx=";4、cin>>x;if(x>0)y=1;elseif(x==0)y=0;elsey=-1;cout<<"y="<5、00000元时,超过50000元部分按3.5%计算奖金;当L超过100000元时,超过100000元部分按4%计算奖金。由键盘输入L的值,编程计算相应的奖金并输出。【源程序】#includevoidmain(){doubleL,S;cout<<"pleaseinputL=";cin>>L;26if(L<5000)S=L*0.015;elseif(L<10000)S=75+(L-5000)*0.02;elseif(L<20000)S=175+(L-10000)*0.025;6、elseif(L<50000)S=175+250+(L-20000)*0.03;elseif(L<100000)S=175+250+900+(L-50000)*0.035;elseS=175+250+900+1750+(L-100000)*0.04;cout<<"S="<voi7、dmain(){intage;cout<<"Pleaseinputage:";cin>>age;switch(age/10){case0:cout<<"A--儿童";break;case1:cout<<"B--少年";break;case2:cout<<"C--青年";break;case3:case4:cout<<"D--中年";break;default:cout<<"E--老年";break;}}实验四循环结构程序设计4.编程题⑴输入n,求1+2+3+……+n的和。#i8、ncludevoidmain(){26inti,n;doublesum=0;cin>>n;for(i=1;i<=n;i++)sum+=i;cout<<"1+2+3+...+"<voidmain(){charch,maxchar;cout<<"pleaseinputtencharacter:";cin>>ch;maxchar=
3、ostream.h>voidmain(){charx,max;cout<<"Pleaseinputthreecharacterss:";cin>>x;max=x;cin>>x;26if(x>max)max=x;cin>>x;if(x>max)max=x;cout<<"max="<0)-1(x<0)【源程序】#includevoidmain(){intx,y;cout<<"Pleaseinputx=";
4、cin>>x;if(x>0)y=1;elseif(x==0)y=0;elsey=-1;cout<<"y="<5、00000元时,超过50000元部分按3.5%计算奖金;当L超过100000元时,超过100000元部分按4%计算奖金。由键盘输入L的值,编程计算相应的奖金并输出。【源程序】#includevoidmain(){doubleL,S;cout<<"pleaseinputL=";cin>>L;26if(L<5000)S=L*0.015;elseif(L<10000)S=75+(L-5000)*0.02;elseif(L<20000)S=175+(L-10000)*0.025;6、elseif(L<50000)S=175+250+(L-20000)*0.03;elseif(L<100000)S=175+250+900+(L-50000)*0.035;elseS=175+250+900+1750+(L-100000)*0.04;cout<<"S="<voi7、dmain(){intage;cout<<"Pleaseinputage:";cin>>age;switch(age/10){case0:cout<<"A--儿童";break;case1:cout<<"B--少年";break;case2:cout<<"C--青年";break;case3:case4:cout<<"D--中年";break;default:cout<<"E--老年";break;}}实验四循环结构程序设计4.编程题⑴输入n,求1+2+3+……+n的和。#i8、ncludevoidmain(){26inti,n;doublesum=0;cin>>n;for(i=1;i<=n;i++)sum+=i;cout<<"1+2+3+...+"<voidmain(){charch,maxchar;cout<<"pleaseinputtencharacter:";cin>>ch;maxchar=
5、00000元时,超过50000元部分按3.5%计算奖金;当L超过100000元时,超过100000元部分按4%计算奖金。由键盘输入L的值,编程计算相应的奖金并输出。【源程序】#includevoidmain(){doubleL,S;cout<<"pleaseinputL=";cin>>L;26if(L<5000)S=L*0.015;elseif(L<10000)S=75+(L-5000)*0.02;elseif(L<20000)S=175+(L-10000)*0.025;
6、elseif(L<50000)S=175+250+(L-20000)*0.03;elseif(L<100000)S=175+250+900+(L-50000)*0.035;elseS=175+250+900+1750+(L-100000)*0.04;cout<<"S="<voi
7、dmain(){intage;cout<<"Pleaseinputage:";cin>>age;switch(age/10){case0:cout<<"A--儿童";break;case1:cout<<"B--少年";break;case2:cout<<"C--青年";break;case3:case4:cout<<"D--中年";break;default:cout<<"E--老年";break;}}实验四循环结构程序设计4.编程题⑴输入n,求1+2+3+……+n的和。#i
8、ncludevoidmain(){26inti,n;doublesum=0;cin>>n;for(i=1;i<=n;i++)sum+=i;cout<<"1+2+3+...+"<voidmain(){charch,maxchar;cout<<"pleaseinputtencharacter:";cin>>ch;maxchar=
此文档下载收益归作者所有