??
查看原帖
??
992134
weiyi8910楼主2024/9/7 21:13
#include <bits/stdc++.h>
using namespace std;
char a[100001], b[100001],A[10001],B[10001],j;

int main() {
	cin>>a>>b;
	for(int i=strlen(a)-1,e=0; i>=0; i--,e++) {
		A[i]=a[e];
	}
	for(int i=strlen(b)-1,e=0; i>=0; i--,e++) {
		B[i]=b[e];
	}
	j=max(strlen(b),strlen(a));
	for(int i=0; i<=j-1; i++) {
		if(A[i]==0) {
			A[i]='0';
		}
		if(B[i]==0) {
			B[i]='0';
		}
	}
	for(int i=0; i<=j-1; i++) {
		A[i]=A[i]-'0';
		B[i]=B[i]-'0';
		B[i]=A[i]+B[i];
		if(B[i]>=10) {
			B[i]=B[i]%10;
			B[i]=B[i+1]+1;
		}
	}
	for(int i=0; i<=j-1; i++) {
		B[i]=B[i]+'0';
	}
	for(int i=j-1; i>=0; i--) {
		cout<<B[i];
	}
	return 0;
}
2024/9/7 21:13
加载中...