博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdoj1002
阅读量:4599 次
发布时间:2019-06-09

本文共 1840 字,大约阅读时间需要 6 分钟。

A - A + B Problem II

I 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 Input

21 2112233445566778899 998877665544332211

Sample Output

Case 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 1111111111111111110 这道题一开始的思路是直接用字符数组去处理,做到一半发现实在太麻烦了,百度到他们把他放在整形数组里去处理好理解且方便. 且此题有BUG,我的程序输入1 9和1 99999999999这类数时候答案总是0,但是依然AC了- -!(玄学改变命运),不过最后还是改了一下,使程序更完美, 把进位的变量进行判断TM=1输出TM,else continue; 下面是我的程序:
1 #include
2 using namespace std; 3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 int max(int a,int b)11 {12 return a>b?a:b;13 }14 int main()15 {16 char a1[1010],b1[1010];17 int a[1010],b[1010],c[1010];18 int t,i,j;19 cin>>t;20 for(int k=1;k<=t;k++)21 {22 memset(a1,0,sizeof(a1));23 memset(b1,0,sizeof(b1));24 memset(a,0,sizeof(a));25 memset(b,0,sizeof(b));26 memset(c,0,sizeof(c));27 cin>>a1>>b1;28 int lena,lenb;29 lena=strlen(a1);30 lenb=strlen(b1);31 for(i=0,j=lena-1;i
=lenb)41 {42 for(i=0;i

 

 

转载于:https://www.cnblogs.com/dulute/p/7210160.html

你可能感兴趣的文章
UIButton(改变Title和image位置)
查看>>
Linux-使用之vim编译安装出现的问题
查看>>
codevs 3314 魔法森林
查看>>
mac os x mysql 出现./mysql: unknown variable 'sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABL 问题...
查看>>
桐桐的贸易--WA
查看>>
历届试题 高僧斗法
查看>>
linux命令系列 stat & touch
查看>>
[Tools] Webstorm Github的配置与使用
查看>>
鬼谷子绝学
查看>>
Mongodb 笔记04 特殊索引和集合、聚合、应用程序设计
查看>>
使用Post/Redirect/Get实现Asp.net防止表单重复提交
查看>>
用Html5与Asp.net MVC上传多个文件
查看>>
lambda函数,常用函数,内置函数(string,zip()map()filter())的用法
查看>>
Xcode中匹配的配置包的存放目录
查看>>
JavaScript将具有父子关系的原始数据格式化成树形结构数据(id,pid)
查看>>
CSS3.0——背景属性
查看>>
【转载】C语言中的undefined behavior/unspecified behavior - 序
查看>>
MySQL服务使用
查看>>
C语言练手自己编写学生成绩管理系统
查看>>
20175204 张湲祯 2018-2019-2《Java程序设计》第二周学习总结
查看>>