50pts求助
查看原帖
50pts求助
1029575
Alg_orithm楼主2025/8/4 17:18

为什么呢?

#include<bits/stdc++.h>
using namespace std;
const int N=110;
struct people
{
	string no;
	int age,i;
}a[N],old[N];
string str;
bool cmp(people x,people y)
{
	return x.i<y.i;
}
bool comp(people x,people y)
{
	if(x.age==y.age) return x.i<y.i;
	return x.age>y.age;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
	int n,i,j,x,___=0,____=0;	
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>str>>x;
		if(x>=60) old[++___].age=x,old[___].no=str;
		else a[++____].no=str,a[____].age=x,a[____].i=i; 
	}
	sort(a+1,a+___+1,cmp);
	sort(old+1,old+____+1,comp);
	for(i=1;i<=___;i++) cout<<old[i].no<<'\n';
	for(i=1;i<=____;i++) cout<<a[i].no<<'\n';
	return 0;
}
2025/8/4 17:18
加载中...