标签:i++ clu span color space names namespace bsp turn
#include<iostream> #include<stdio.h> #include<math.h> #include<string.h> using namespace std; char a[1005]; char b[1005]; int aa[1005]; int bb[1005]; int c[1005]; int main() { while(~scanf("%s%s",a,b)) { memset(aa,0,sizeof(aa)); memset(bb,0,sizeof(bb)); int lena = strlen(a); int lenb = strlen(b); for(int i = lena -1 ; i >= 0 ; i--) { aa[lena - i -1] = a[i] - ‘0‘; } for (int i = lenb -1 ; i >= 0; i--) { bb[lenb - i - 1] =b[i] - ‘0‘; } int lenc = lena > lenb ? lena : lenb; int jinwei = 0; for(int i = 0 ; i < lenc; i++) { c[i] = (aa[i]+bb[i]+jinwei)%10; jinwei = (aa[i]+bb[i]+jinwei)/10; } if(jinwei != 0) { c[lenc++] = jinwei; } for(int i =lenc - 1; i >= 0; i--) { printf("%d",c[i]); } puts(""); } return 0; }
标签:i++ clu span color space names namespace bsp turn
原文地址:http://www.cnblogs.com/hhkobeww/p/7657621.html