如果你RE(特别是用了cmp函数)
查看原帖
如果你RE(特别是用了cmp函数)
533102
monodev楼主2024/8/3 16:57

记得加上 a==b 时的判定(虽然我也不知道为什么不加会炸,见下)

bool greaterthan(const string& a, const string& b) {
	if (a.length() == b.length()) {
		for (size_t i = 0; i < a.length(); ++i) {
			if (a[i] < b[i]) {
				return false;
			}
			if (a[i] > b[i]) {
				return true;
			}
		}
		return false; // If equal
	} else {
		return a.length() > b.length();
	}
}
2024/8/3 16:57
加载中...