资源描述:
《杭电acm答案无敌版》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、选修课考试作业2012素数判定332014青年歌手大奖赛_评委会打分342017字符串统计402019数列有序!412020绝对值排序432033人见人爱A+B462039三角形482040亲和数49姓名:春杰级:电商141001SumProblemProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n. InputTheinputwillconsistofaseriesofint
2、egersn,oneintegerperline. OutputForeachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger. SampleInput1100 SampleOutput15050 AuthorDOOMIII解答:#includemain(){intn,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;i<=n;i++)su
3、m+=i;printf("%d",sum);}}1089A+BforInput-OutputPractice(I)ProblemDescriptionYourtaskistoCalculatea+b.Tooeasy?!Ofcourse!Ispeciallydesignedtheproblemforacmbeginners.Youmusthavefoundthatsomeproblemshavethesametitleswiththisone,yes,alltheseproblemsweredesignedforthesameaim. InputTheinputwill
4、consistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline. OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput. SampleInput151020 SampleOutput630 Authorlcy RecommendJGShining解答:#includemain(){in
5、ta,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d",a+b);}1090A+BforInput-OutputPractice(II)ProblemDescriptionYourtaskistoCalculatea+b. InputInputcontainsanintegerNinthefirstline,andthenNlinesfollow.Eachlineconsistsofapairofintegersaandb,separatedbyaspace,onepairofintegersperline. OutputForea
6、chpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput. SampleInput2151020 SampleOutput630 Authorlcy RecommendJGShining解答:#include#defineM1000voidmain(){inta,b,n,j[M],i;//printf("pleaseinputn:");scanf("%d",&n);for(i=0;i7、nf("%d%d",&a,&b);//printf("%d%d",a,b);j[i]=a+b;}i=0;while(i