0分蒟蒻求助
查看原帖
0分蒟蒻求助
1041765
AKkkk_TIX楼主2024/8/9 18:41
#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, ans = 0;
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])
                    ans++;

    cout << ans;
    return 0;
}

记录详情

2024/8/9 18:41
加载中...