提交时间:2024-05-05 17:24:35

运行 ID: 145827

#include <bits/stdc++.h> using namespace std; int main() { char a[20002]={0}, b[20002]={0}; cin>>a>>b; int alen = strlen(a), blen = strlen(b), t = 0, i; int a1[20200]={0}, b1[20002]={0}; for (i = 0; i < alen; i++) a1[i] = a[alen-1-i]-'0'; for (i = 0; i < blen; i++) b1[i] = b[blen-1-i]-'0'; alen = (alen > blen) ? alen : blen; for (i = 0; i <= alen; i++) t = a1[i]+b1[i], a1[i] = t%10, a1[i+1] += t/10; while (!a1[i] && i) i--; for(; i >= 0; i--) cout<<a1[i]; return 0; }