文章

38

粉丝

11

获赞

2

访问

17.4k

头像
日志排序 题解:75%通过写cmp用sort(a,a+n,cmp)
P1227 北京大学机考题
发布于2024年8月26日 16:51
阅读数 673

#include<bits/stdc++.h>
using namespace std;
struct Log{
    char name[12];
    int y,month,d,h,minute,s,hs;
    double time;
}stu[10100];
bool cmp(Log a,Log b){
    if(a.time != b.time) return a.time < b.time;
    else if(a.y != b.y) return a.y < b.y;
    else if(a.month != b.month) return a.month < b.month;
    else if(a.d != b.d) return a.d < b.d;
    else if(a.h != b.h) return a.h < b.h;
    else if(a.minute != b.minute) return a.minute < b.minute;
    else if(a.s != b.s) return a.s < b.s;
    else return a.hs < b.hs;
}
int main(){
    int i = 0;

    while(scanf("%s %d-%d-%d %d:%d:%d,%d %lf(s)",&stu[i].name,&stu[i].y,&stu[i].month,&stu[i].d,&stu[i].h,&stu[i].minute,&stu[i].s,&stu[i].hs,&stu[i].time) != EOF){
            i++;
...

登录查看完整内容


登录后发布评论

1 条评论
1664178416
2024年8月28日 12:50

请问大佬后面成功AC了吗?可以请教一下解法吗

赞(0)