样例通过了,感觉没啥问题啊。。。怎么全是WA。。
查看原帖
样例通过了,感觉没啥问题啊。。。怎么全是WA。。
335679
85180220st楼主2020/7/5 22:50
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3;
struct student
{
	string name;
	int chinese;
	int math;
	int english;
};
student stu[N];
bool judge(student a, student b)//判断满足条件的学生
{
	if (abs(a.chinese - b.chinese) <= 5 && abs(a.math - b.math <= 5) && abs(a.english - b.english <= 5) && abs(a.chinese + a.math + a.english - b.chinese - b.math - b.english) <= 10)
		return true;
	else
		return false;
}
int main()
{
	int n, i, j;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> stu[i].name >> stu[i].chinese >> stu[i].math >> stu[i].english;
	for (i = 0; i < n; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			if (judge(stu[i], stu[j]) == true)
				cout << stu[i].name << " " << stu[j].name << endl;
		}
	}
	return 0;
}
2020/7/5 22:50
加载中...