64分求助!
查看原帖
64分求助!
937201
Abu_Dumbledore楼主2023/11/11 19:09

有大佬帮我看看哪里错了吗,最后两个测试点WA(感谢


64分代码:

#include<bits/stdc++.h>
using namespace std;
int y,m,d,q;//年,月,日,共q个数据
struct str{
	string n;//姓名
	long long int j;//=y*10000+m*100+d
    int i;//输入序号
}a[101];
bool cmp(str a, str b){
    if(a.j<b.j) return 1;
    else if(a.j==b.j){
        if(a.i<b.i) return 1;
        else return 0;
    }
    else return 0;
}
int main(){
    cin>>q;
    for(int w=1;w<=q;w++){
        cin>>a[w].n>>y>>m>>d;
        a[w].i=w;
        a[w].j=y*10000+m*100+d;
    }
    stable_sort(a+1,a+q+1,cmp);
    for(int w=1;w<=q;w++){
        cout<<a[w].n<<endl;
    }
} 
2023/11/11 19:09
加载中...