YJZWX @ 2023-11-22 13:29:28
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+15;
struct sb{
string xm;
int nf,yf,nyt;
int srs;
}a[N];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i].xm>>a[i].nf>>a[i].yf>>a[i].nyt;
a[i].srs=a[i].nf*10000+a[i].yf*100+a[i].nyt*1;
}
sort(a+1,a+1+n);
for(int i=1;i<=n;++i)
cout<<a[i].xm<<endl;
}
by PNNNN @ 2023-11-22 13:34:37
结构体不能直接sort,要写一个比较函数
by kmlihaiming @ 2023-11-22 14:01:14
struct sb
你写这个名怎么可能给你编
by wangziwenhk @ 2023-11-22 14:17:27
再写一个cmp函数
bool cmp(sb a,sb b){
if(判断条件1是否相等){
return 条件1 < 条件2
}
else if(判断条件2是否相等)
...
}
by YJZWX @ 2023-11-23 19:07:51
@kmlihaiming 这是英文的somebody别想歪
by YJZWX @ 2023-11-23 19:08:22
@PNNNN 谢谢,过了
by YJZWX @ 2023-11-23 19:09:09
@wangziwenhk 谢谢,刚好不知道怎么写呢
by kmlihaiming @ 2023-11-24 13:24:31
@YJZWX 哈哈,不愧是鼬神