#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+9;
int a[N];
int b[N];
int c[N];
int main(){
string str1,str2;
cin>>str1>>str2;
int len1 = str1.size(),len2 = str2.size();
for(int i=1,j=len1-1;i<=len1;++i,--j)
{
a[i]=str1[j]-'0';
// cout<<a[i]<<" " ;
}
for(int i=1,j=len2-1;i<=len2;++i,--j)
{
b[i]=str2[j]-'0';
}
int mx = max(len1,len2);
for(int i=1;i<=mx;++i)
{
c[i] = a[i]+b[i]+c[i];
c[i+1] = c[i]/10;
c[i] = c[i]%10;
}
while(c[mx+1])mx++;
for(int i=mx;i>=1;i--) cout<<c[i];
return 0;
}
高精度加法
最新推荐文章于 2025-05-24 09:58:06 发布