#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a,b; string m,n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--){ a.push_back(m[i]-'0'); } for(int i=n.size()-1;i>=0;i--){ b.push_back(n[i]-'0'); } vector<int> c(a.size()+b.size()+2,0); int sum=0; int x_size=max(a.size(),b.size()); for(int i=0;i<x_size;i++){ if(i>=a.size()){ a.push_back(0); } if(i>=b.size()){ b.push_back(0); } c[i]+=a[i]+b[i]; } for(int i=0;i<x_size||sum;i++){ sum+=c[i]; c[i]=sum%10; sum=sum/10; } while(c.size()>1&&c.back()==0){ c.pop_back(); } for(int i=c.size()-1;i>=0;i--){ cout<<c[i]; } return 0; }
标签:高精度,int,back,--,push,size From: https://www.cnblogs.com/wangyueshuo/p/18226020