有没有大神看看最后一个点为啥出错
查看原帖
有没有大神看看最后一个点为啥出错
678390
Chosen1njyd楼主2023/3/18 11:25
#include<bits/stdc++.h>
using namespace std;
typedef struct CourseTime{
    int num;
    int a;
    int b;
    int total;
}Ct;
bool cmp(Ct lhs,Ct rhs){
    if(lhs.total<rhs.total){
        return true;
    }else if(lhs.total==rhs.total&&lhs.num>rhs.num){
        return true;
    }else{
        return false;
    }
}
int main()
{
    Ct ct[7];
    memset(&ct,0,sizeof(ct));
    for(int i=0;i<7;i++){
        ct[i].num=i;
        cin>>ct[i].a>>ct[i].b;
        ct[i].total=ct[i].a+ct[i].b;
    }
    sort(ct,ct+7,cmp);
    for(int i=6;i>=0;i--){
        if(ct[i].total>8){
            cout<<ct[i].num+1<<endl;
            break;
        }
    }
    return 0;
}
2023/3/18 11:25
加载中...