#include <iostream> #include <cmath> #include <vector> using namespace std; int main(){ string a,b; cin>>a>>b; bool a1 = true,b1 = true; for(int i = 0;i<max(a.size(),b.size());i++){ if(i<a.size() && a[i]!='0'){ if(a1){ a = a.substr(i); a1 = false; } } if(i<b.size() && b[i]!='0'){ if(b1){ b = b.substr(i); b1 = false; } } } vector<int> x,y,sum; for(int i = a.size()-1;i>=0;i--){ x.push_back(a[i]-'0'); } for(int i = b.size()-1;i>=0;i--){ y.push_back(b[i]-'0'); } int j = 0; for(int i = 0;i<max(x.size(),y.size()) || j;i++){ if(i<x.size()){ j += x[i]; } if(i<y.size()){ j += y[i]; } sum.push_back(j%10); j /= 10; } for(int i = sum.size()-1;i>=0;i--){ cout<<sum[i]; } return 0; }
标签:高精度,int,1168,back,--,奥赛,include From: https://www.cnblogs.com/wangyihang-xh/p/18212429