0分求助
查看原帖
0分求助
1041765
AKkkk_TIX楼主2024/8/8 13:26
#include <bits/stdc++.h>
using namespace std;
struct stu {
	string name;
	int chinese, math, english, total;
	friend istream & operator >> ( istream &in, stu &x ) {
		cin >> x.name >> x.chinese >> x.math >> x.english;
	    return cin;
	}
	bool operator < ( stu x ) const {
		return ( 
		         abs(chinese - x.chinese < 5) && 
		         abs(math - x.math < 5) &&                           
		         abs(english - x.english < 5) &&
		         abs(total - x.total < 10)
		                                            );
	}
}a[1010];
int n, i, j;
int main(){
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a[i];
		a[i].total = a[i].chinese + a[i].math + a[i].english;
	}
	
	for(int i = 0;i < n;i++)
	    for(int j = 0;j < n;j++)
	        if(i == j)
	            continue;
	        else 
	            if(a[i] < a[j])
	                cout << a[i].name << a[j].name;
	
	return 0;
}

记录详情

2024/8/8 13:26
加载中...