HDU_1002
来源:互联网 发布:java nodejs 比较 编辑:程序博客网 时间:2024/04/29 10:52
#include<stdio.h>#include<string.h>int main(){ char a[1000],b[1000],c[1001]; int i,j=0,p=0,n,n1,n2; scanf("%d",&n); while(n--) { scanf("%s %s",a,b); printf("Case %d:\n",++j); printf("%s + %s = ",a,b); n1=strlen(a)-1; n2=strlen(b)-1; for(i=0;n1>=0||n2>=0;i++,n1--,n2--) { if(n1>=0&&n2>=0) {c[i]=a[n1]+b[n2]-'0'+p;} if(n1>=0&&n2<0) {c[i]=a[n1]+p;} if(n1<0&&n2>=0) {c[i]=b[n2]+p;} p=0; if(c[i]>'9'){c[i]=c[i]-10;p=1;} } if(p==1){printf("%d",p);} while(i--) {printf("%c",c[i]);} if(n!=0){printf("\n\n");} else {printf("\n");} } return 0;}
0 0
- HDU_1002
- hdu_1002 A + B Problem II
- HDU_1002 A + B Problem II
- HTML JS 调用Cordys WebService
- html5---上传文件
- 【LeetCode】205.Isomorphic Strings
- 栈的实现javascript
- python实现大整数相乘---格子乘法
- HDU_1002
- 算法导论笔记:32字符串匹配算法
- jQuery自定义选择符
- hdu 2066 一个人的旅行
- 进程模块枚举与隐藏
- Windows不能在本地计算机启动Apache2
- Reactor模型
- UIbutton的三个不同内边距含义
- wust D we love design