資源描述:
《杭電ACM水題題目及代碼.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫(kù)。
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;}成績(jī)轉(zhuǎn)換TimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):25250AcceptedSubmission(s):10776ProblemDescription輸入一個(gè)
7、百分制的成績(jī)t,將其轉(zhuǎn)換成對(duì)應(yīng)的等級(jí),具體轉(zhuǎn)換規(guī)則如下:90~100為A;80~89為B;70~79為C;60~69為D;0~59為E;Input輸入數(shù)據(jù)有多組,每組占一行,由一個(gè)整數(shù)組成。Output對(duì)于每組輸入數(shù)據(jù),輸出一行。如果輸入數(shù)據(jù)不在0~100范圍內(nèi),請(qǐng)輸出一行:“Scoreiserror!”。SampleInput5667100123SampleOutputEDAScoreiserror!AuthorlcySourceC語言程序設(shè)計(jì)練習(xí)(一)RecommendJGShining#includeintmain(){intn,
8、k;while(scanf("%d",&n)!=EOF){if(n<0
9、
10、n>1