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