- ACM
【结构体排序习题:拔河比赛】
- 2024-11-8 16:46:01 @
#include<iostream>
#include<algorithm>
using namespace std;
struct Stu{
int id,w; //学号id 重量w
};
Stu a[105];
int n; //人数n
bool cmp(Stu x,Stu y) { //按重量从大到小排序
return x.w > y.w;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].id >> a[i].w;
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++)
cout << a[i].id << endl;
return 0;
}
0 comments
No comments so far...