0分蒟蒻求助

P1104 生日

kkkSb_O3 @ 2023-11-19 15:14:05

#include<bits/stdc++.h>
using namespace std;
struct qqq 
{
    string m;
    int n,y,r,id;
}a[105];
int n;
bool cmn(qqq x,qqq y)
{
    if(x.n!=y.n)
        return x.n<y.n;
    else if(x.y!=y.y)
        return x.y<y.y;
    else if(x.r!=x.r)
        return x.r<y.r;
    else
        return x.id>y.id;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].m>>a[i].n>>a[i].y>>a[i].r;
        a[i].id=i;
    }
    sort(a+1,a+n+1,cmn);
    for(int i=1;i<=n;i++)
    {
        cout<<a[i].m<<"\n";
    }
}

by lzm0107 @ 2023-11-19 15:22:05

《0分》


by Hatsune_Miku_ @ 2023-11-19 15:50:58

cmn中

else if(x.r!=x.r)
    return x.r<y.r;

判断条件打错了


by kkkSb_O3 @ 2023-11-19 20:30:55

@HatsuneMiku 谢谢


by bcbgszyzh @ 2023-11-24 11:00:32

a了吗?


|