二年级小学生求助,重发,哪错了??

P1093 [NOIP2007 普及组] 奖学金

神贴搬运工 @ 2020-07-31 13:27:36

#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x1,x2,x3,zong,id;
}a[1001];
bool cmp(node x,node y)
{
    if(x.zong!=y.zong)
    {
        return x.zong>y.zong;
    }
    else
    {
        return x.id<y.id;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i].x1>>a[i].x2>>a[i].x3;
        a[i].id=i;
        a[i].zong=a[i].x1+a[i].x2+a[i].x3;
    }
    sort(a+1,a+n+1,cmp);
    for(i=1;i<=5;i++)
    {
        cout<<a[i].id<<" "<<a[i].zong<<"\n";
    }
}

by 冰糖鸽子 @ 2020-07-31 13:29:55

请先删贴谢谢


by liuyongle @ 2020-07-31 13:29:56

两个贴了,删一个吧,您这样连着发。。。


by 仗剑_天涯 @ 2020-07-31 13:30:07

一页两贴危


by 猫猬兽 @ 2020-07-31 13:31:22


by liuyongle @ 2020-07-31 13:31:25

自删吧


by DeepSkyBlue__ @ 2020-07-31 13:31:57

@神贴搬运工 考虑语文,然后应该是return x.x1>y.x1


by 神贴搬运工 @ 2020-07-31 13:33:58

@FDY_ManchesterCity 我以前加了,是五十分,去掉变成70分


by DeepSkyBlue__ @ 2020-07-31 13:34:55

@神贴搬运工

bool cmp(node x,node y)
{
    if(x.zong!=y.zong) return x.zong>y.zong;
    if(x.x1!=y.x1) return x.x1>y.x1;
    if(x.id!=y.id) return x.id<y.id;
}

把cmp改成这样试试?


by y0y68 @ 2020-07-31 13:35:12

真·二年级小学生?


by y0y68 @ 2020-07-31 13:35:35

真·神贴搬运工?


| 下一页