zoukankan      html  css  js  c++  java
  • 1062 Talent and Virtue (25)

      1 /*
      2 
      3 
      4 L (>=60), the lower bound of the qualified grades -- 
      5 that is, only the ones whose grades of talent and virtue are both not below
      6 this line will be ranked; 
      7 
      8 and H (<100), the higher line of qualification
      9 
     10 
     11 ,those with both grades not below this line are considered as the "sages",
     12 and will be ranked in non-increasing order according to their total grades. 
     13 
     14 Those with talent grades below H but virtue grades not are cosidered as 
     15 the "noblemen", and are also ranked in non-increasing order according to 
     16 their total grades, but they are listed after the "sages". 
     17 
     18 
     19 Those with both grades below H, 
     20 but with virtue not lower than talent are considered as the "fool men".
     21 They are ranked in the same way but after the "noblemen". 
     22 
     23 
     24 The rest of people whose grades both pass the L line are ranked 
     25 after the "fool men".
     26 
     27 
     28 
     29 */
     30 
     31 #include <string.h>
     32 #include <algorithm>
     33 #include <vector>
     34 #include <stdio.h>
     35 using namespace std;
     36 
     37 struct peo
     38 {
     39     char num[9];
     40     int all,t,v;
     41     int id;
     42 };
     43 
     44 bool cmp(peo a,peo b)
     45 {
     46     if(a.id==b.id)
     47     {
     48         if(a.all == b.all)
     49         {
     50             if(a.v == b.v )
     51                 return (strcmp(a.num,b.num)<0);
     52             else return a.v > b.v;
     53         }
     54         else return a.all > b.all;
     55     }
     56     else return a.id<b.id;
     57 
     58 }
     59 
     60 int main()
     61 {
     62 
     63     int i,n,low,high,v,t;
     64     char num[9];
     65     while(scanf("%d%d%d",&n,&low,&high)!=EOF)
     66     {
     67 
     68         vector<peo> VP;
     69         for(i=0;i<n;i++)
     70         {
     71             getchar();
     72             scanf("%s %d %d",num,&v,&t);
     73             if(t>=low && v>=low)
     74             {
     75                 peo pp;
     76                 strcpy(pp.num,num);
     77                 pp.v=v;
     78                 pp.t=t;
     79                 pp.all=v+t;
     80                 if(v>=high && t>=high)
     81                     pp.id=1;
     82                 else if(v>= high && t<high)
     83                     pp.id=2;    
     84                 else if(v< high && t< high && v>=t)
     85                     pp.id=3;
     86                 else 
     87                     pp.id=4;
     88 
     89                 VP.push_back(pp);
     90             }
     91         }
     92 
     93         sort(VP.begin(),VP.end(),cmp);
     94         printf("%d
    ",VP.size());
     95         for(i=0;i<VP.size();i++)
     96             printf("%s %d %d
    ",VP[i].num,VP[i].v,VP[i].t);
     97 
     98     }
     99     return 0;
    100 }
  • 相关阅读:
    debian下使用mplayer
    Linux缺点要挟网银平安 SSL证书遽需改换
    linux用C如何鉴别一个目录能否为空
    Ubuntu旗舰版(Ultimate)1.8
    Linux系统下IP以及DNS设置方法
    升级firefox 3.0 beta 到RC1
    微星下月推Wind超低价NB 可运转XP和Linux
    Linux下hosts、host.conf、resolv.conf的区别
    传华硕将在6月3日闪现EBox台式电脑
    linux批改ssh端口和避免root远程上岸设置
  • 原文地址:https://www.cnblogs.com/xiaoyesoso/p/4265171.html
Copyright © 2011-2022 走看看