29行,不用慌
2025-08-13 17:11:06
发布于:江西
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct Stu{
string id;
int age;
int sx;
}p[101];
bool cmp(Stu a,Stu b)
{
if(a.age<60 && b.age < 60) return a.sx<b.sx;
else if(a.age>=60 && b.age >=60){
if(a.age ==b.age) return a.sx< b.sx;
else return a.age > b.age;
}else
return a.age > b.age;
}
int main()
{
int n;
cin >> n;
for(int i=1;i<=n ;i++)
{
cin>>p[i].id >> p[i].age;
p[i].sx = i;
}
sort(p+1,p+n+1,cmp);
for(int i =1;i <= n; i++) cout << p[i].id << endl;
return 0;
}
这里空空如也
有帮助,赞一个