帮debug qmq
查看原帖
帮debug qmq
957641
stayup楼主2024/8/9 17:48

60分 3、5点

#include<bits/stdc++.h>
using namespace std;
#define int long long
string a,b;
int x[10000010],y[10000010],z;
signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>a>>b;
	memset(x,0,sizeof x);
	memset(y,0,sizeof y);
	for(int i=0;i<a.length();i++){
		x[i]=a[i]-'0';
	}
	reverse(x,x+a.length());
	for(int i=0;i<b.length();i++)y[i]=b[i]-'0';
	reverse(y,y+b.length());
	int len1=a.length(),len2=b.length();
	for(int i=0;i<max(len1,len2);i++){
		x[i]+=y[i]+z;
		z=0;
		z=x[i]/10;
		x[i]%=10;
	}
	if(z!=0)x[len1]=z;
	len1++;
	reverse(x,x+len1);
	for(int i=0;i<len1;i++){
		if(i==0&&x[i]==0)continue;
		cout<<x[i];
	}
	return 0;
}

帮改悬关

2024/8/9 17:48
加载中...