杭电题目acm答案[1].doc
- 文档编号:157292
- 上传时间:2022-10-04
- 格式:DOC
- 页数:54
- 大小:234KB
杭电题目acm答案[1].doc
《杭电题目acm答案[1].doc》由会员分享,可在线阅读,更多相关《杭电题目acm答案[1].doc(54页珍藏版)》请在冰豆网上搜索。
选修课考试作业
1001SumProblem 2
1089A+BforInput-OutputPractice(I) 4
1090A+BforInput-OutputPractice(II) 6
1091A+BforInput-OutputPractice(III) 8
1092A+BforInput-OutputPractice(IV) 9
1093A+BforInput-OutputPractice(V) 11
1094A+BforInput-OutputPractice(VI) 12
1095A+BforInput-OutputPractice(VII) 13
1096A+BforInput-OutputPractice(VIII) 14
2000ASCII码排序 16
2001计算两点间的距离 17
2002计算球体积 19
2003求绝对值 20
2004成绩转换 21
2005第几天?
22
2006求奇数的乘积 24
2007平方和与立方和 26
2008数值统计 27
2009求数列的和 28
2010水仙花数 29
2011多项式求和 31
2012素数判定 33
2014青年歌手大奖赛_评委会打分 34
2015偶数求和 36
2016数据的交换输出 38
2017字符串统计 40
2019数列有序!
41
2020绝对值排序 43
2021发工资咯:
) 45
2033人见人爱A+B 46
2039三角形 48
2040亲和数 49
姓名:
郑春杰
班级:
电商1001
学号:
1010504134
1001SumProblem
ProblemDescription
Hey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).
Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n.
Input
Theinputwillconsistofaseriesofintegersn,oneintegerperline.
Output
Foreachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger.
SampleInput
1
100
SampleOutput
1
5050
Author
DOOMIII
解答:
#include
main()
{
intn,i,sum;
sum=0;
while((scanf("%d",&n)!
=-1))
{
sum=0;
for(i=0;i<=n;i++)
sum+=i;
printf("%d\n\n",sum);
}
}
1089A+BforInput-OutputPractice(I)
ProblemDescription
YourtaskistoCalculatea+b.
Tooeasy?
!
Ofcourse!
Ispeciallydesignedtheproblemforacmbeginners.
Youmusthavefoundthatsomeproblemshavethesametitleswiththisone,yes,alltheseproblemsweredesignedforthesameaim.
Input
Theinputwillconsistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline.
Output
Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.
SampleInput
15
1020
SampleOutput
6
30
Author
lcy
Recommend
JGShining
解答:
#include
main()
{
inta,b;
while(scanf("%d%d",&a,&b)!
=EOF)
printf("%d\n",a+b);
}
1090A+BforInput-OutputPractice(II)
ProblemDescription
YourtaskistoCalculatea+b.
Input
InputcontainsanintegerNinthefirstline,andthenNlinesfollow.Eachlineconsistsofapairofintegersaandb,separatedbyaspace,onepairofintegersperline.
Output
Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.
SampleInput
2
15
1020
SampleOutput
6
30
Author
lcy
Recommend
JGShining
解答:
#include
#defineM1000
voidmain()
{
inta,b,n,j[M],i;
//printf("pleaseinputn:
\n");
scanf("%d",&n);
for(i=0;i { scanf("%d%d",&a,&b); //printf("%d%d",a,b); j[i]=a+b; } i=0; while(i { printf("%d",j[i]); i++; printf("\n"); } } 1091A+BforInput-OutputPractice(III) ProblemDescription YourtaskistoCalculatea+b. Input Inputcontainsmultipletestcases.Eachtestcasecontainsapairofintegersaandb,onepairofintegersperline.Atestcasecontaining00terminatestheinputandthistestcaseisnottobeprocessed. Output Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput. SampleInput 15 1020 00 SampleOutput 6 30 Author lcy Recommend JGShining 解答: #include main() { inta,b; scanf("%d%d",&a,&b); while(! (a==0&&b==0)) { printf("%d\n",a+b); scanf("%d%d",&a,&b); } } 1092A+BforInput-OutputPractice(IV) ProblemDescription YourtaskistoCalculatethesumofsomeintegers. Input Inputcontainsmultipletestcases.EachtestcasecontainsaintegerN,andthenNintegersfollowinthesameline.Atestcasestartingwith0terminatestheinputandthistestcaseisnottobeprocessed. Output Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andwithonelineofoutputforeachlineininput. SampleInput 41234 512345 0 SampleOutput 10 15 Author lcy Recommend JGShining 解答: #include intmain() { intn,sum,i,t; while(scanf("%d",&n)! =EOF&&n! =0) { sum=0; for(i=0;i { scanf("%d",&t); sum=sum+t; } printf("%d\n",sum); } } 1093A+BforInput-OutputPractice(V) Problem
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 题目 acm 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)