求助结构体排序
查看原帖
求助结构体排序
551088
FincheuwYggdrasil楼主2022/5/22 18:03
#include<bits/stdc++.h>
using namespace std;
const int maxn = 105; 
struct a{
   int score;
   string no;
   string name;
} stu[maxn];

int main()
{
	int x,y;
	cin >> x;
	y = x;
	for(int i = 0;i < x;i++)
	{
		cin >> stu[i].name >> stu[i].no >> stu[i].score;
	}
	sort(stu,stu+x-1);
	cout << stu[y - 1].name << stu[y - 1].no;
	cout << stu[0].name << stu[0].no;
 	return 0;
}

rt,但我只想排序score

2022/5/22 18:03
加载中...