MuYuMC @ 2024-05-07 21:00:01
#include <iostream>
#include <cstring>
using namespace std;
int A[2000];
int B[2000];
int sum[99999];
int main()
{
int n,i,k;
string s1,s2;
cin >> s1 >> s2;
A[0] = s1.size();
B[0] = s2.size();
for(i = 1;i <= s1.size();i++)
{
A[i] = s1[A[0] - i] - '0';
}
for(i = 1;i <= s2.size();i++)
{
B[i] = s2[B[0] - i] - '0';
}
k = max(A[0],B[0]);
for(i = 1;i <= k;i++)
{
A[i + 1] += (A[i] + B[i]) / 10;
A[i] = (A[i] + B[i]) % 10;
}
if(A[k + 1] != 0)k++;
for(i = k;i >= 1;i--)cout << A[i];
return 0;
}
by jesse1216 @ 2024-05-07 21:17:47
你没考虑负数。 @MuYuMC
by MuYuMC @ 2024-05-07 21:23:43
@jesse1216 谢谢
by wangyucheng6229 @ 2024-05-25 19:32:44
不用这么麻烦
by wangyucheng6229 @ 2024-05-25 19:36:59
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}