牛客网题目链接
高精度加法
经典题
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cctype>
#include <unordered_map>
#include <map>
using namespace std;
const int N = 105;
typedef pair<int, string> PII;
int main() {
string a, b;
while(cin>>a>>b){
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int c = 0;
string res;
for(int i = 0; i < a.size() || i < b.size(); i++){
int u = i < a.size()? a[i]-'0' : 0;
int v = i < b.size()? b[i]-'0' : 0;
int t = u + v + c;
res += char(t % 10 + '0');
c = t / 10;
}
if(c) res += '1';
reverse(res.begin(), res.end());
cout<<res<<endl;
}
return 0;
}