lwjppz 2018-12-04 12:06 采纳率: 0%
浏览 288

这题要怎么做?代码尽量简单一点

![图片说明](https://img-ask.csdn.net/upload/201812/04/1543925117_755327.png)图片说明

  • 写回答

1条回答 默认 最新

  • 02Irving11 2019-07-12 16:02
    关注
    #include<bits/stdc++.h>
    #define maxn (1005)
    using namespace std;
    
    struct Student
    {
      int Math,Chinese,English;
      int total;
      int num;
      bool operator < (const Student &other) const
      {
        if(total != other.total)
          return total > other.total;
        else
          return Chinese > other.Chinese;
      }
    }student[maxn];
    
    int main()
    {
      int n;
      cin >> n;
      for(int i = 0;i < n;i++)
      {
        student[i].num = i+1;
        cin >> student[i].Chinese >> student[i].Math >> student[i].English;
        student[i].total = student[i].Chinese + student[i].Math + student[i].English;
      }
      sort( student , student + n );
      for(int i = 0;i < n;i++)
      {
        cout << student[i].num << ' ' << student[i].total << endl;
      }
      return 0;
    }
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 react-diff-viewer组件,如何解决数据量过大卡顿问题
  • ¥20 遥感植被物候指数空间分布图制作
  • ¥15 安装了xlrd库但是import不了…
  • ¥20 Github上传代码没有contribution和activity记录
  • ¥20 SNETCracker
  • ¥15 数学建模大赛交通流量控制
  • ¥15 为什么我安装了open3d但是在调用的时候没有报错但是什么都没有发生呢
  • ¥50 paddleocr最下面一行似乎无法识别
  • ¥15 求某类社交网络数据集
  • ¥15 靶向捕获探针方法/参考文献