- 1、本文档共75页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
杭电ACM水题题目及代码_精品
1002 A + B Problem IITime Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 69615????Accepted Submission(s): 12678Problem 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#include stdio.h#include string.hint main(){char str1[1001], str2[1001];int t, i, len_str1, len_str2, len_max, num = 1, k;scanf(%d, t);getchar();while(t--){int a[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(%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:\n, num);num++;printf(%s + %s = , str1, str2);if(c[len_max] == 1)printf(1);for(i = len_max - 1; i = 0; --i){printf(%d, c[i]);}printf(\n);if(t = 1)printf(\n);}return 0;}成绩转换Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25250 Accep
您可能关注的文档
- 机械设计基础考试题02及答案及复习指导,考前汇总_精品.doc
- 机械设计课程设计说明书-胶带传输机卷筒传动装置设计_精品.doc
- 机械设计课程设计计算说明书-慢动卷扬机传动装置设计(含图纸)_精品.doc
- 机械课程设计(论文)-锤片式饲料粉碎机设计(全套图纸三维)_精品.pdf
- 机械通气及相关问题_精品.ppt
- 机械设计课程设计说明书-运输机的蜗杆圆柱齿轮减速器_精品.doc
- 机械设计课程设计说明书-带式运输机传动装置的一级蜗杆蜗轮减速器设计_精品.doc
- 机械设计课程设计-螺旋式输送机传动装置_精品.doc
- 机油知识_精品.doc
- 机电一体化_毕业论文-机电一体化在农业机械上的应用_精品.doc
文档评论(0)