zoukankan      html  css  js  c++  java
  • 砂漠の公園 [MISSION LEVEL: B]

     1 #include <bits/stdc++.h>
     2 #define _for(i,a,b) for(int i = (a);i < (b);i ++)
     3 #define pb push_back
     4 using namespace std;
     5 
     6 struct TEAM
     7 {
     8     int num;
     9     int win;
    10     int dogfall;
    11     int lose;
    12     int score;
    13 };
    14 
    15 int cmp(const void *a,const void *b)
    16 {
    17     TEAM *c = (TEAM *)a;
    18     TEAM *d = (TEAM *)b;
    19     if(c->score < d->score)
    20         return 1;
    21     return -1;
    22 }
    23 
    24 void show(TEAM *teamList,int n)
    25 {
    26     _for(j,0,n)
    27     printf("%d %d %d %d %d
    ",teamList[j].num,teamList[j].score,
    28         teamList[j].win,teamList[j].dogfall,teamList[j].lose);
    29 }
    30 
    31 int main()
    32 {
    33     int n;
    34     while(cin >> n)
    35     {
    36         TEAM teamList[n];
    37         memset(teamList,0,sizeof(teamList));
    38         _for(i,0,n)
    39             teamList[i].num = i+1;
    40         _for(i,0,n)
    41         {
    42             _for(j,0,n)
    43             {
    44                 char tmp;
    45                 cin >> tmp;
    46                 if(tmp=='W')
    47                 {
    48                     teamList[i].win ++;
    49                     teamList[i].score += 2;
    50                 }
    51                 else if(tmp=='D')
    52                 {
    53                     teamList[i].dogfall ++;
    54                     teamList[i].score += 1;
    55                 }
    56                 else if(tmp=='L')
    57                 {
    58                     teamList[i].lose ++;
    59                 }
    60             }
    61         }
    62         qsort(teamList,n,sizeof(TEAM),cmp);
    63     //    show(teamList,n);
    64         printf("%d %d %d %d %d",teamList[0].num,teamList[0].score,
    65         teamList[0].win,teamList[0].dogfall,teamList[0].lose);
    66     }
    67     return 0;
    68 }
  • 相关阅读:
    数据结构
    查找算法
    排序算法
    ThreadPoolExecutor
    Python map()函数
    Python惰性序列
    Python iterator迭代器
    Python yield关键字 和 Generator(生成器)
    Python 列表生成式(List Comprehensions)
    Python 迭代(iteration)
  • 原文地址:https://www.cnblogs.com/Asurudo/p/10313040.html
Copyright © 2011-2022 走看看