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

运行 ID: 145824

#include <bits/stdc++.h> using namespace std; int main() { char a[202]={0}, b[202]={0}; cin>>a>>b; int alen = strlen(a), blen = strlen(b), t = 0, i; int a1[202]={0}, b1[202]={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; }