题解
2023-08-05 18:37:36
发布于:浙江
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1,s2;
const int N = 1e6+5;
int len1,len2,len,i,j;
int a[N];
int b[N];
int c[N];
int main(){
cin>>s1>>s2;
len1 = s1.length();
len2 = s2.length();
len = max(len1,len2);
for(i = 0;i < len1;i++){
a[i] = s1[len1-1-i] - '0';
}
for(i = 0;i < len2;i++){
b[i] = s2[len2-1-i] - '0';
}
for(i = 0;i < len;i++){
c[i] += a[i] + b[i];
c[i+1] += c[i] / 10;
c[i] %= 10;
}
if(c[len]){
len++;
}
for(i = len-1;i >= 0;i--){
cout<<c[i];
}
return 0;
}
这里空空如也
有帮助,赞一个