高处不胜辰 @ 2021-02-24 10:06:38
#include<bits/stdc++.h>
using namespace std;
const int maxn=550;
char a1[maxn],b1[maxn];
int a[maxn],b[maxn],x,y;
int main()
{
gets(a1);
gets(b1);
int lena=strlen(a1);
int lenb=strlen(b1);
int max=lena>lenb?lena:lenb;
for(int i=0;i<lena;i++)
{
a[i]=a1[lena-i-1]-'0';
}
for(int i=0;i<lenb;i++)
{
b[i]=b1[lenb-i-1]-'0';
}
for(int i=0;i<max;i++)
{
a[i]+=b[i];
if(a[i]>=10)
{
a[i+1]+=1;
a[i]=a[i]%10;
}
}
if(a[max]>0) max++;
for(int i=max-1;i>=0;i--) printf("%d",a[i]);
return 0;
}
by JJA_ @ 2021-02-24 10:12:20
@编程小白hunt gets容易出锅
by 高处不胜辰 @ 2021-02-24 10:14:08
@蒟蒻JJA 那请问大佬:该怎么改?
by qqqqq111 @ 2021-02-26 21:53:56
@编程小白hunt cin,getline是个好东西