警钟撅烂
查看原帖
警钟撅烂
762086
Francium_楼主2023/8/13 15:33
#include <bits/stdc++.h>
using namespace std;
#define MAXX 10100
int a[MAXX], b[MAXX], c[MAXX];

bool check(string x, string y) {
	if (x.size() != y.size())
		return x.size() > y.size();
	else
		return x > y;
}

int main() {
	string A, B;
	cin >> A >> B;
	if (!check(A, B)) {
		string C = A;
		A = B;
		B = C;
		cout << "-";
	}
	int len = max(A.length(), B.length());
	for (int i = A.length() - 1, j = 1; i >= 0; i--, j++) {
		a[j] = A[i] - '0';
	}
	for (int i = B.length() - 1, j = 1; i >= 0; i--, j++) {
		b[j] = B[i] - '0';
	}
	for (int i = 1; i <= len; i++) {
		if (a[i] - b[i] < 0) {
			a[i] += 10;
			a[i + 1] -= 1;
		}
		c[i] = a[i] - b[i];
	}
	while (!c[len--]);
	for (int i = len + 1; i >= 1; i--)
		cout << c[i];
	return 0;
}

就是这份代码,90分\text {90分} 下开数据一看,0! 远来妹判断0的情况 所以发此贴(警钟长撅)

2023/8/13 15:33
加载中...