资源描述:
《杭电ACM水题题目及代码.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、1002A+BProblemIITimeLimit:2000/1000MS(Java/Others) MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):69615 AcceptedSubmission(s):12678ProblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B. InputThefirstlineoftheinputcont
2、ainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers,AandB.Noticethattheintegersareverylarge,thatmeansyoushouldnotprocessthembyusing32-bitinteger.Youmayassumethelengthofeachintegerwillnotexceed1000. OutputForeachtestcase,yo
3、ushouldoutputtwolines.Thefirstlineis"Case#:",#meansthenumberofthetestcase.Thesecondlineistheanequation"A+B=Sum",SummeanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases. SampleInput212 SampleOutputCase1:1+2=3Case2:+= AuthorIgnatius.L#include
4、#includeintmain(){charstr1[1001],str2[1001];intt,i,len_str1,len_str2,len_max,num=1,k;scanf("%d",&t);getchar();while(t--){inta[1001]={0},b[1001]={0},c[1001]={0};scanf("%s",str1);len_str1=strlen(str1);for(i=0;i<=len_str1-1;++i)a[i]=str1[len_str1-1-i]-'0';scanf("%
5、s",str2);len_str2=strlen(str2);for(i=0;i<=len_str2-1;++i)b[i]=str2[len_str2-1-i]-'0';if(len_str1>len_str2)len_max=len_str1;elselen_max=len_str2;k=0;for(i=0;i<=len_max-1;++i){c[i]=(a[i]+b[i]+k)%10;k=(a[i]+b[i]+k)/10;}if(k!=0)c[len_max]=1;printf("Case%d:",num);num++;printf("%s+%s
6、=",str1,str2);if(c[len_max]==1)printf("1");for(i=len_max-1;i>=0;--i){printf("%d",c[i]);}printf("");if(t>=1)printf("");}return0;}成绩转换TimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):25250AcceptedSubmission(s):10776ProblemDescription输入一个
7、百分制的成绩t,将其转换成对应的等级,具体转换规则如下:90~100为A;80~89为B;70~79为C;60~69为D;0~59为E;Input输入数据有多组,每组占一行,由一个整数组成。Output对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Scoreiserror!”。SampleInput5667100123SampleOutputEDAScoreiserror!AuthorlcySourceC语言程序设计练习(一)RecommendJGShining#includeintmain(){intn,
8、k;while(scanf("%d",&n)!=EOF){if(n<0
9、
10、n>1