64啊喂!!!

P1104 生日

Wang_xin_chen @ 2024-07-09 08:53:20

#include<bits/stdc++.h>
using namespace std;
int n;
struct ll{
    string name;
    int year,month,day,level;
}a[10005];
bool cmp(ll a,ll b){
    if(a.year==b.year){
        if(a.month==b.month){
            if(a.day==b.day) return a.level<b.level;
            else return a.day<b.day;
        }
        else return a.month<b.month;
    }
    else return a.year<b.year;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].name>>a[i].year>>a[i].month>>a[i].day;
        a[i].level=i;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++) cout<<a[i].name<<endl;
    return 0;
}

by yangyang826 @ 2024-07-09 09:16:27

a.level<b.level改成a.level>b.level


by Wang_xin_chen @ 2024-07-21 11:04:27

@yangyang826 谢谢 ,AC了


|