HDU 1002 A + B Problem II
来源:互联网 发布:淘宝卖家app叫什么 编辑:程序博客网 时间:2024/05/17 13:13
大数相加题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002
#include<stdio.h>#include<string>#define maxn 1010int a[maxn], b[maxn];int main(){ int s,len1,len2,i,j,k,up,count=1; char str1[1001],str2[1001]; scanf("%d", &s); for(j=0;j<s;j++) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); scanf("%s",str1); scanf("%s",str2); len1=strlen(str1); len2=strlen(str2); for(i=len1-1,k=0;i>=0;i--) { a[k++]=str1[i]-'0'; } for(i=len2-1,k=0;i>=0;i--) { b[k++]=str2[i]-'0'; } for(i=0,up=0;i<maxn;i++) { a[i]=a[i]+b[i]+up; up=a[i]/10; a[i]=a[i]%10; } for(i=maxn-1;i>=0;i--) if(a[i]) break; printf("Case %d:\n", count++); printf("%s + %s = ",str1,str2); for(k=i;k>=0;k--) printf("%d", a[k]); printf("\n"); if(j<s-1)//**格式**// printf("\n"); } return 0;}
- HDU 1002 A + B Problem II
- HDU 1002A + B Problem II
- HDU 1002 - A + B Problem II
- HDU 1002 A + B Problem II
- HDU 1002 A + B Problem II
- HDU 1002 A + B Problem II
- HDU 1002 A + B Problem II
- HDU 1002 A + B Problem II
- hdu 1002 A+B Problem II
- HDU 1002 A + B Problem II
- hdu 1002 A + B Problem II
- HDU 1002 A + B Problem II (BigNums)
- hdu 1002 A + B Problem II
- hdu 1002 A + B Problem II
- hdu 1002 A + B Problem II
- HDU 1002 A + B Problem II
- HDU 1002 A + B Problem II
- Hdu---A + B Problem II---1002
- 软件版本常识和软件版本号命名规则
- mysql服务器远程访问
- 非MFC中使用Cstring
- oracle 进程查看v$session
- UBuntu下USB转串口配置
- HDU 1002 A + B Problem II
- Mysql安装
- 摘自代码阅读方法与实践书籍的知识点总结
- ZFI001应收账龄
- 全文索引如果关键字少于3个字符就会查不到
- Eclipse快捷键大全
- 分配内存错误
- linux源代码阅读技巧
- Java GUI