我全WA了,求助
查看原帖
我全WA了,求助
266774
wdzxghl楼主2020/6/26 07:28
#include<bits/stdc++.h>
using namespace std;
const int maxn=2001;
string s,s1;
int a[maxn],b[maxn],c[maxn];
int main(){
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));	
	memset(c,0,sizeof(c));	
	getline(cin,s);
	getline(cin,s1);
	int len=s.size();
	int len1=s1.size();
	int len2=max(len,len1);
	for(int i=0;i<len2;i++)a[i+1]=s[i]-'0';
	for(int i=0;i<len2;i++)b[i+1]=s1[i]-'0';
	for(int i=1;i<=len2;i++){
		int x=a[i]+b[i];
		c[i]+=x%10;
		c[i+1]+=(x/10);
		//cout<<x<<" "<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
	}
	int k=0;
	while(c[k]==0)
	k++;
	for(int i=k;i<=len2;i++)
	cout<<c[i];
	return 0;
}
2020/6/26 07:28
加载中...