啊为什么只有20分,求大佬解答!
查看原帖
啊为什么只有20分,求大佬解答!
502665
Sunny__Le楼主2021/3/28 12:30
#include<iostream>
#include<math.h>
using namespace std;
struct stu
{
	int chi;
	int math;
	int eng;
	int sum;
}stu[1001];
int main()
{
	int n, count = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> stu[i].chi >> stu[i].math
        >> stu[i].eng;
		stu[i].sum = stu[i].chi +tu[i].eng + stu[i].math;
	}
	for(int i = 1; i < n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			if(fabs(stu[i].chi - stu[j].chi) <= 5 
				&& fabs(stu[i].eng - stu[j].eng) <= 5 
				&& fabs(stu[i].math - stu[j].math)<= 5 
				&& fabs(stu[i].sum - stu[j].sum <= 10))
				count ++;
		}
	}
	cout << count;
	return 0;
}
2021/3/28 12:30
加载中...