Eternal_rainbow @ 2024-12-01 13:53:06
#include <bits/stdc++.h>
using namespace std;
int n;
struct p
{
string s;
int y,m,d,num;
}p[105];
bool cmp(struct p a,struct p b)
{
return a.num <= b.num;
}
int main()
{
cin >> n;
for (int i = 1;i <= n;i++)
{
cin >> p[i].s >> p[i].y >> p[i].m >> p[i].d;
p[i].num = p[i].y * 10000 + p[i].m * 100 + p[i].d;
}
sort(p + 1,p + n + 1,cmp);
for (int i = 1;i <= n;i++)
{
cout << p[i].s << endl;
}
return 0;
}
by Eternal_rainbow @ 2024-12-01 13:53:50
改了个等号W6变W5了
by Eternal_rainbow @ 2024-12-01 13:54:09
大佬help
by ckn0915 @ 2024-12-01 16:20:59
@Eternal_rainbow
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string d[n];
int a[n],b[n],c[n];
for(int i=0;i<n;i++){
cin>>d[i]>>a[i]>>b[i]>>c[i];
}
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(a[i]>a[j]){
swap(a[i],a[j]);
swap(b[i],b[j]);
swap(c[i],c[j]);
swap(d[i],d[j]);
}
else if(a[i]==a[j]){
if(b[i]>b[j]){
swap(a[i],a[j]);
swap(b[i],b[j]);
swap(c[i],c[j]);
swap(d[i],d[j]);
}
if(b[i]==b[j]){
if(c[i]>c[j]){
swap(a[i],a[j]);
swap(b[i],b[j]);
swap(c[i],c[j]);
swap(d[i],d[j]);
}
}
}
}
}
for(int i=0;i<n;i++) cout<<d[i]<<endl;
return 0;
}
by ckn0915 @ 2024-12-01 16:21:37
80分
by ckn0915 @ 2024-12-01 16:22:22
https://www.luogu.com.cn/record/192301886