求助,本地能跑,提交wa
查看原帖
求助,本地能跑,提交wa
35296
hawk_condor楼主2020/11/15 19:33
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	int x,y;
	x=a.length();
	int a1[100],b1[100];
	for(int i=0;i<=x-1;i++)
		a1[i+1]=a[x-i-1]-'0';
	y=b.length();
	for(int i=0;i<=y-1;i++)
		b1[i+1]=b[y-i-1]-'0';
	for(int i=1;i<=y;i++)
	{
		a1[i]+=b1[i];
		if(a1[i]>=10);
		{
			int c=a1[i]/10;
			a1[i+1]+=c;
			a1[i]%=10;
		} 
	}
	if(x>=y)
	{
		if(a1[x+1]!=0)
		{
			for(int i=x+1;i>=1;i--)
			{
				printf("%d",a1[i]);
			}
			cout<<endl;
			return 0;
		}
		else
		{
			for(int i=x;i>=1;i--)
			{
				printf("%d",a1[i]);
			}
			cout<<endl;
			return 0;
		}
	}
	else
	{
		if(a1[y+1]!=0)
			{
				for(int i=y+1;i>=1;i--)
				{
					printf("%d",a1[i]);
				}
				cout<<endl;
				return 0;
			}
			else
			{
				for(int i=y;i>=1;i--)
				{
					printf("%d",a1[i]);
				}
				cout<<endl;
				return 0;
			}	
	}
}
2020/11/15 19:33
加载中...