提交时间:2024-03-16 02:12:43
运行 ID: 43427
#include <bits/stdc++.h> using namespace std; int a[210], b[210], c[201]; int main(){ string x, y; cin >> x >> y; int len = x.size(), len1 = y.size(); int l = max(len,len1); for(int i = len-1;i>=0;i--) { a[len-i-1] = x[i] - '0'; } for(int i = len1-1;i>=0;i--) { b[len1-i-1] = y[i] - '0'; } for(int i = 0; i < len; i++) { c[i] = b[i] + a[i]; if(c[i] > 10) { c[i+1] += c[i] / 10; c[i] %= 10; } } bool f = 0; for(int i = l+1; i >= 0; i--) { if(i==0 || c[i]!=0 ) { f = 1; } if(f) cout << c[i]; } return 0; }