#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
string a, b, res;
cin>>a>>b;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int c = 0;
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 += to_string(t % 10);
c = t / 10;
}
if(c != 0) res += '1';
reverse(res.begin(), res.end());
cout<<res<<endl;
return 0;
}
791. 高精度加法
最新推荐文章于 2022-12-24 13:21:30 发布