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

本文共 2186 字,大约阅读时间需要 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

 

转载地址:http://ctysa.baihongyu.com/

你可能感兴趣的文章
java关联vss 80020009,80020009: Invalid password[src=SourceSafe,guid=null]
查看>>
java复制文件到指定文件夹下,java:把一个文件夹中的所有文件复制到指定文件夹下...
查看>>
matlab足球赛排名问题程序,足球队排名问题及解决方法.doc
查看>>
ubuntu php5-imap,在Ubuntu 11上安装具有IMAP / Kerberos支持的PHP的问题
查看>>
php圣经 源码,基于PHP的圣经读者用剑模块和diatheke
查看>>
php中的$this-%3efetch,Zend DB fetchAll(): where子句數組帶有IN操作符
查看>>
李思琼php,nginx单机1w并发优化
查看>>
怎么手动设置oracle,手把手设置win7系统手动启动Oracle服务的设置方法
查看>>
oracle fk作用,oracle pk&fk
查看>>
oracle裂块是什么意思,Oracle索引块分裂split信息汇总
查看>>
php构造函数创建对象,7.10 构造函数来创建对象
查看>>
oracle解密后台包,oracle9i加密解密包用法
查看>>
oracle数据库nmon日志在哪,oracle技术之nmon使用说明
查看>>
oracle10g实例修改表空间,oracle10g建表空间和修改oracle字符和删除表空间和用户(加 标注)...
查看>>
linux命令语法规则,Linux系统tar命令怎么使用语法规则
查看>>
linux查看服务器静态路由配置,配置Linux静态路由和配置IP
查看>>
linux应用程序使用时钟中断,Linux时钟中断(2.6.23)(三)
查看>>
win7读取linux硬盘序列号,Windows 下获取硬盘序列号
查看>>
linux音频设备接口,OSS--跨平台的音频接口简介
查看>>
华为网卡linux驱动安装,Linux Nvidia显卡驱动安装
查看>>