收藏 分销(赏)

期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx

上传人:精*** 文档编号:3469754 上传时间:2024-07-07 格式:PPTX 页数:16 大小:251.14KB
下载 相关 举报
期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx_第1页
第1页 / 共16页
期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx_第2页
第2页 / 共16页
期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx_第3页
第3页 / 共16页
期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx_第4页
第4页 / 共16页
期末考试补充测验市公开课一等奖百校联赛特等奖课件.pptx_第5页
第5页 / 共16页
点击查看更多>>
资源描述

1、期末考试补充测验第第1页页1.Sumofevennumbers2DescriptionGivenanumberN(evenorodd),calculate2+4+.+n(nisthelargestevennumbersmallerthanN).Printoutthesum.InputThefirstlineisanintegerm,indicatingthenumberoftestcases.Thenfollowmlines.TheilinecontainsapositivenumberN_i.OutputForeachnumberN_i,printthesumof2+4+.+n_i(n_ii

2、sthelargestevennumbersmallerthanN_i)inasingleline.SampleInput258SampleOutput620第第2页页1.Sumofevennumbers3#includeusingnamespacestd;intmain()intcount,num,sum;cincount;for(inti=0;inum;sum=0;for(intj=2;j=num;j+=2)sum+=j;coutsumendl;第第3页页2.GradeRecordManagement4DescriptionTherearesomestudentsgraderecords,

3、informatof“namegrade”.Inordertoeasetheviewandmanagementoftherecordseasily,youareaskedtodevelopaprogramtoprintouttherecordsaccordingtothegrades.Thatis,thenamesareprintedintheorderofgrades.InputTotally,thereare8recordsandeachrecordoccupiesaline.Onlylettersanddigitsappearinthenameofastudent(i.e.therewi

4、llbenospaceinaname).Eachnamecontainsatmost20lettersor(and)digits.Allgradesareintegersintherangeof0100.OutputEachgradeperline,followedbythestudentshavingthisgrade.Forstudentshavingthesamegrade,theyarelistedinthesameline,withthesameorderasintheinput.Hints:Youcanusetwoarraystostorethenamesandgrades.Sam

5、pleInputWangYi90LiMing90HuRui50ZhangLi65LiLei80ZhangFei65ZhaoSan70ChenZi100SampleOutput100ChenZi90WangYiLiMing80LiLei70ZhaoSan65ZhangLiZhangFei50HuRui第第4页页2.GradeRecordManagement5#defineSIZE8#defineLEN25intmain()charnameSIZELEN;intgradeSIZE;for(inti=0;inamei;cingradei;/rankfor(inti=SIZE-1;i0;-i)for(

6、intj=0;ji;+j)if(gradejgradej+1)chartmpLEN;strcpy(tmp,namej);strcpy(namej,namej+1);strcpy(namej+1,tmp);inttmp2=gradej;gradej=gradej+1;gradej+1=tmp2;/printfor(inti=0;iSIZE;+i)if(i=0|gradeigradei-1)coutgradei;coutgradei+1)coutsalpcnttarget;while(sal0)yr=1;sum=12*sal;while(sumtarget)sal+=(sal*pcnt)/100;

7、sum+=12*sal;yr+;coutyrsalpcnttarget;第第8页页2.StringReversion9DescriptionGivenavalididentifierinCprograms,pleasewriteaprogramtoreverseitbyrespectivelyreversingtwopartsseparatedby_.InputThefirstlineisanintegerm,indicatingthenumberoftestcases.Thentherearemlinesandeachlinecontainsastring.Astringwillcontai

8、nnomorethan100charactersandthereisoneorless_.OutputForeachtestcase,printoutthestringreversed.SampleInput2John_Smithint_45_meSampleOutputnhoJ_htimStni_54_em第第9页页StringReversion10voidreversePart(char,int,int);/reversepartofthestringintmain()intcount;cincount;for(intx=0;xstr;for(inti=0;istrlen(str);i+)

9、if(stri=_)mark=i;break;reversePart(str,0,mark-1);reversePart(str,mark+1,strlen(str)-1);coutstrhigh)return;for(inti=low;ich;while(ch!=#)/Initialzevairalbeforeachlineofinputfor(inti=0;i-1&countlast0ch;if(countdigit0countdigit1)countdigit0=countdigit1;/Sortthenumbersintmax,tmp1,tmp2;/Setthesecondcolumn

10、tobedigits0.9;for(inti=0;i=9;i+)counti1=i;for(inti=0;i=9;i+)max=findMax(count,i);tmp1=counti0;tmp2=counti1;counti0=countmax0;counti1=countmax1;countmax0=tmp1;countmax1=tmp2;/Printouttheresultsfor(inti=0;i0)coutcounti1(counti0);if(i0)cout,;elsecoutch;intfindMax(intcount2,intlow)intmax=low;for(inti=lo

11、w+1;icountmax0)max=i;elseif(counti0=countmax0&counti1countmax1)max=i;returnmax;第第12页页4.Changetouppercase13DescriptionGivenalinecontainsmultiplewords,changethefirstcharacterineachwordtouppercase.InputAlinecontainingmultiplewords.Thelinecontainslessthan100characters.OutputThesamelinewiththefirstcharac

12、terofeachwordbeinguppercase.SampleInputPleasechangemetoupper-case.SampleOutputPleaseChangeMeToUpper-case.第第13页页Changetouppercase14intlength(char*string1)for(inti=0;+i)if(string1i=0)returnI;chartoUpperCase(charc)if(c=a&c=z)return(char)(c-(a-A);returnc;voidtoUpperCase(char*string1,char*string2)intleng

13、th1=length(string1);inttimes=0;intstatus=1;for(inti=0;ilength1;+i)if(string1i=)string2i=string1i;status=1;elseif(status=1)string2i=toUpperCase(string1i);elsestring2i=string1i;status=0;intmain()charstring1100;charstring2100;cin.getline(string1,100);toUpperCase(string1,string2);coutstring2;第第14页页5.Cyc

14、lingthewords15DescriptionGivenalinecontainsNwords,printtheNlines.Thefirstlineisthesameastheinput.Afterprintingeachline,thefirstwordofthislineinputtotheendofthenextline.InputAlinecontainsNwords.Nisnotgivenintheproblem:youneedtocountthenumberofwordsintheinputlinetofinditout.Thelinecontainslessthan100c

15、haracters.OutputNlines.Thefirstlineequalstheinput.FortherestN-1lines,thefirstwordinalineinputtotheendinthenextline.SampleInputPleasethinkaboutitcarefullySampleOutputPleasethinkaboutitcarefullythinkaboutitcarefullyPleaseaboutitcarefullyPleasethinkitcarefullyPleasethinkaboutcarefullyPleasethinkaboutit

16、第第15页页Cyclingthewords16intlength(char*string1)for(inti=0;+i)if(string1i=0)returni;intsplit(char*string1,char*string2)intlength1=length(string1);intcount=1;for(inti=0;ilength1;+i)string2i=string1i;if(string1i=)+count;string2i=0;returncount;voidprint(char*string1)intlength1=length(string1);intwords=sp

17、lit(string1,string1);intstart=0;for(inti=0;iwords;+i)intstart2=start;for(intj=i;jwords;+j)cout(string1+start2);start2+=length(string1+start2)+1;start2=0;for(intj=0;ji;+j)cout(string1+start2);start2+=length(string1+start2)+1;coutendl;start+=length(string1+start)+1;intmain()charstring1100;cin.getline(string1,100);print(string1);第第16页页

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服