第三和第五个样例没过
查看原帖
第三和第五个样例没过
1040753
KARA_214楼主2024/8/28 13:08
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
char a[505],b[505];
int x,y,cnt(0),f[505],tmp(0),hhh(0);
int main(){
	cin>>a>>b;
	x=strlen(a);
	y=strlen(b);
	while(x>0||y>0){
		int zz=((a[x-1]-'0')+(b[y-1]-'0')+cnt);
		if(zz<10){
			f[tmp]=zz;
			tmp++;
			cnt=0;
		}else{
			f[tmp]=zz-10;
			tmp++;
			cnt=1;
		}
		x--;y--;
	}
	if(f[tmp]==0){
		cout<<1;
	}
	for(int i=tmp-1;i>=0;i--){
		cout<<f[i];
	}
	return 0;
}

似乎遇到特别大的数过不去,烦请解答

2024/8/28 13:08
加载中...