P1104求调
  • 板块学术版
  • 楼主liweizhe1904
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/10/13 09:18
  • 上次更新2024/10/13 11:41:33
查看原帖
P1104求调
1208356
liweizhe1904楼主2024/10/13 09:18
#include<bits/stdc++.h>
using namespace std;
struct b{
    string n;
    int y;
    int m;
    int d;
    int u;
}a[150];
int k,i;
bool cmp(b e,b f){
    if(e.y<f.y){
        return 1;
    }
    if(e.y==f.y){
        if(e.m<f.m){
            return 1;
        }
        if(e.m==f.m){
            if(e.d<f.d){
                return 1;
            }
            if(e.d==f.d){
                        if(e.u>f.u){
          return 1;
                }
            }else{
                return 0;
            }    
        }else{
            return 0;
        }        
    }else{
        return 0;
    }            
}
int main(){
    cin>>k;
    for(i=1;i<=k;i++){
        cin>>a[i].n>>a[i].y>>a[i].m>>a[i].d;
        a[i].u=i;
    }
    sort(a+1,a+1+k,cmp);
    for(i=1;i<=k;i++){
        cout<<a[i].n<<endl;
    }    
    return 0;
}
2024/10/13 09:18
加载中...