zoukankan      html  css  js  c++  java
  • 最终排名 结构体

                                                                                                         最终排名

    Description

    第四届山东理工大学ACM网络编程擂台赛比赛完后需要产生一个最终排名,排名按照题数多少来决定。但是有太多的队伍参与,手动计算排名已经不能满足比赛的需求。现在有一份名单记录各个队伍的ID和做出的题目数,需要你写一个程序,产生最终的排名。

    为了简化题目,这里的排名规则为:做出题目数量多的队伍排在前面,如果题数相等,保持输入时的相对顺序不要改变

    Input

      第一行包含一个正整数T( 1≤T≤15),表示有T组测试数据。每组数据第一行有一个正整数N(1< N≤10000),表示队伍数量。接下来N 行包含两个整数,1≤ID≤10^7, 0≤M≤100。ID为队伍的编号,M为做出的题数。

    Output

      每组数据输出包含N行,第i行有两个整数,ID和M表示排在第i位的队伍的ID和做出的题数。

    Sample Input

    1
    8
    1 2
    16 3
    11 2
    20 3
    3 5
    26 4
    7 1
    22 4
    

    Sample Output

    3 5
    26 4
    22 4
    16 3
    20 3
    1 2
    11 2
    7 1

    Hint

     

    #include<iostream>
    using namespace std;
    struct list{
      int id, m;
    }team[10000], tmp;
    int main(){
        int t;
        cin>>t;
        while(t--){
            int n, i;
            cin>>n;
            for(i=0; i<n; i++)
               cin>>team[i].id>>team[i].m;
            for(i=0; i<n; i++)
              for(int j=n-1; j>i; j--)
              if(team[j].m > team[j-1].m)
              {
                  tmp = team[j];
                  team[j] = team[j-1];
                  team[j-1] = tmp;
              }
            for(i=0; i<n; i++)
              cout<<team[i].id<<" "<<team[i].m<<endl;
        }
    return 0;
    }
    


  • 相关阅读:
    set命令_Linux
    AngularJS的date 过滤器
    JMeter环境介绍
    JMeter测试计划要素
    HTTP协议的压缩及URL Encode
    fiddler配置及使用教程
    Slenium常用方法
    Selenium八大定位
    CSS实现上下左右垂直居中
    SASS用法笔记
  • 原文地址:https://www.cnblogs.com/Genesis2018/p/9079912.html
Copyright © 2011-2022 走看看