大佬救命,全WA(样例过了)
查看原帖
大佬救命,全WA(样例过了)
833898
yichens楼主2022/11/24 12:45
#include <iostream>
#include<string>
using namespace std;
struct student {
	string name;
	int a;
	int b;
	int c;
};
int sdl(int a, int b) {
	if (a - b < 0) {
		return b - a;
	}
	else {
		return a - b;
	}
}
void sdt(string a, string b) {
	int m = a.length();
	if (m > b.length()) {
		m = b.length();
	}
	for (int i = 0; i < m; i++) {
		if (a[i] < b[i]) {
			cout << a << " " << b << endl;
			break;
		}
		else if (a[i] > b[i]) {
			cout << b << " " <<a<< endl;
			break;
		}
	}
}
int main() {
	int n;
	cin >> n;
	student st[1000];
	for (int i = 0; i < n; i++) {
		cin >> st[i].name;
		cin >> st[i].a;
		cin >> st[i].b;
		cin >> st[i].c;
	}
	int m = n-1;
	for (int i = 0; i < n-1; i++) {
		for (int i1 = i + 1; i1 < n; i1++) {
			int g1 = st[i].a + st[i].b + st[i].c;
			int g2 = st[i1].a + st[i1].b + st[i1].c;
			if (sdl(st[i].a, st[i1].a) <= 5 && sdl(st[i].b, st[i1].b) <= 5 && sdl(st[i].c, st[i1].c) <= 5 && sdl(g1,g2)<= 10) {
				sdt(st[i].name, st[i1].name);
			}
		}
	}
	system("pause");
	return 0;
}
2022/11/24 12:45
加载中...