ACM题库1002 A + B Problem II.docx

  1. 1、本文档共7页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ACM题库1002ABProblemII

A + B Problem IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 307905 Accepted Submission(s): 59515Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. InputThe first line of the input contains an integer T(1=T=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000. OutputFor each test case, you should output two lines. The first line is Case #:, # means the number of the test case. The second line is the an equation A + B = Sum, Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases. Sample Input21 2112233445566778899 998877665544332211 Sample OutputCase 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 1111111111111111110 AuthorIgnatius.L RecommendWe have carefully selected several similar problems for you: 1004 1003 1008 1005 1089 /*思路是首先我先把两个字符串数目相等的运算符重载写好,然后遇见那些位数不相等的,就把位数比较小的前面用零补齐。注意的是,输出结果时,两个CASE之间要有一行空白。遇见99+11或者99+1这种(即结果的位数跟原来两个字符串不同的,就需要新开字符串数组,把第一位补上1,后面的数字依次往后退。*/#includestdio.h#includestring.h //计算字符数目的函数的头文件; int main(){ char a[2000], c[2000], d[2000],f[2000],g[2000]; //题目要求最大是1000,那我直接设个2000的; int e=0,num1,num2; //num1,num2用来存a,c两个字符串的字符数; int i,l=0,j,k,m; scanf(%d,k); //控制有多少个计算式的; for(m=1;mk+1;m++) //注意m从1开始,是为了跟后面的Case m:保持一致; { scanf(%s%s, a,c); num1=strlen(a); num2=strlen(c); if(num1=num2) //判断看是哪个字符串比较大,小的那个前面补0,注意这里是c[0]=0,而不是最后一位变成了0; { j=num1; for(i=0;inum2;i++) { f[i]=c[i]; } f[i]=\0; for(i=0;i=num1-num2-1;i++) { c[i]=0; } for(i=num1-num2;inum1;i++) { c[i]=f[i-(num1-num2)]; } c[i]=\0; } if(num1num2) //同理; { j=num2; for(i=0;inum1;i++) { f[i]=a[i]; } f[i]=\0; for(i=0;i=num

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档