博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDUOJ1002A + B Problem II
阅读量:6078 次
发布时间:2019-06-20

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

A + B Problem II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 120188    Accepted Submission(s): 22865

Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
 

 

Input
The 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.
 

 

Output
For 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
2 1 2 112233445566778899 998877665544332211
 

 

Sample Output
Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110
 
 
View Code
1 #include
2 #include
3 #define maxn 1010 4 int shu1[maxn],shu2[maxn]; 5 char str1[maxn],str2[maxn]; 6 int main() 7 { 8 int n,i,j,len1,len2,k; 9 scanf("%d",&n);10 getchar();11 for(k=1;k<=n;k++)12 {13 scanf("%s",str1);14 scanf("%s",str2);15 printf("Case %d:\n%s + %s = ",k,str1,str2);16 memset(shu1,0,sizeof(shu1));17 memset(shu2,0,sizeof(shu2));18 len1=strlen(str1);19 len2=strlen(str2);20 //printf("lenstr1=%d,lenstr2=%d",len1,len2);//21 for(j=0,i=len1-1;i>=0;i--)22 shu1[j++]=str1[i]-'0';23 for(j=0,i=len2-1;i>=0;i--)24 shu2[j++]=str2[i]-'0';25 for(i=0;i
=10)29 {30 shu1[i]%=10;31 shu1[i+1]++;32 }33 }34 //for(i=0;i
=0;j--)37 if(shu1[j])break;38 if(j==-1)39 printf("0");40 else 41 {42 for(i=j;i>=0;i--)43 printf("%d",shu1[i]);44 }45 if(k

 

转载于:https://www.cnblogs.com/zhaojiedi1992/archive/2012/07/27/zhaojiedi_2012_07_26000.html

你可能感兴趣的文章
动态创建地图文档MXD并发布地图服务
查看>>
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
查看>>
单例模式讲解
查看>>
Linux权限管理(笔记)
查看>>
(笔记)电路设计(二)之串联匹配电阻的应用
查看>>
Linux下的grep搜索命令详解(二)
查看>>
C 基本语法
查看>>
Codeforces Round #258 (Div. 2) A. Game With Sticks 水题
查看>>
Server 2008 R2 事件查看器实现日志分析
查看>>
解决Cookie乱码问题
查看>>
javascript中的链表结构—从链表中删除元素
查看>>
用实例揭示notify()和notifyAll()的本质区别
查看>>
Android MediaPlayer接口及状态迁移
查看>>
JQuery------prevAll(),nextAll(),attr()方法的使用
查看>>
Disciz!NT开源资源汇总
查看>>
Python网络编程笔记
查看>>
Vim自动补全神器–YouCompleteMe
查看>>
Mysql 小工具
查看>>
个人andriod实习小作品,个人联网笔记本
查看>>
Codeforces Round #313 (Div. 2) 解题报告
查看>>