大数加法
#include
#include
#include
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int lenA = a.length();
int lenB = b.length();
int len = max(lenA, lenB) + 2;
string ans(len, '0');
for (int i = 0; i < lenA; i++)
ans[i] = a[i];
int tmp = 0;
for (int i = 0; i < len; i++)
{
if (i < b.length())
{
tmp += (ans[i] - '0') + (b[i] - '0');
}
else
tmp += (ans[i] - '0');
ans[i] = (tmp % 10 + '0');
tmp = tmp / 10;
}
reverse(ans.begin(), ans.end());
ans = ans.substr(ans.find_first_not_of('0'));
cout << ans << endl;
return 0;
}