测试点3和5wa了,实在找不出问题在哪,有没哪位大佬帮帮蒟蒻QAQ
查看原帖
测试点3和5wa了,实在找不出问题在哪,有没哪位大佬帮帮蒟蒻QAQ
497933
wucr12楼主2023/10/22 21:26
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main(){
	string x,y;
	int a[1000],b[1000],c[1000];
	memset(c,0,sizeof(c));
	cin>>x;cin>>y;
	for(int ct=1,i=x.length()-1;i>=0;i--,ct++)
	{
		a[ct]=x[i]-'0';
	}
	for(int ct=1,i=y.length()-1;i>=0;i--,ct++)
	{
		b[ct]=y[i]-'0';
	}
	int max;
	if(x.length()>y.length())	max=x.length();
	else max=y.length();
	for(int i=1;i<=max;i++)
	{
		c[i]=c[i]+a[i]+b[i];
		if(c[i]>=10)
		{
			c[i]-=10;
			c[i+1]++;
		}
	}
	if(c[max+1]!=0)	max++;
	for(int i=max;i>=1;i--)
	{
		cout<<c[i];
	}
	return 0;
}
2023/10/22 21:26
加载中...