A+B
`
考虑高精度
代码
#include<iostream>
using namespace std;
const int N = 510;
int arr[N],aa[N],ab[N];
int main(){
string a,b;
cin>>a;
cin>>b;
int sizea = a.length(),sizeb = b.length();
int len = sizea>sizeb?sizea:sizeb;
for(int i = a.length()-1,index=0;i>=0;i--,index++){
aa[index] = a.at(i)-'0';
}
for(int i = b.length()-1,index=0;i>=0;i--,index++){
ab[index] = b.at(i) - '0';
}
for(int i = 0;i<len;i++){
arr[i] += aa[i]+ab[i];
// cout<<arr[i]<<endl;
arr[i+1]+=arr[i]/10;
arr[i]%=10;
}
if(arr[len])cout<<arr[len];
for(int i = len-1;i>=0;i--){
cout<<arr[i];
}
return 0;
}
标签:index,高精度,int,--,length,sizea,sizeb
From: https://www.cnblogs.com/tsqo/p/16888472.html