• 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 }
  • 相关阅读:
    Java知多少(28)super关键字
    Java知多少(27)继承的概念与实现
    Java知多少(26)源文件的声明规则
    Java知多少(25)再谈Java包
    Java知多少(24)包装类、拆箱和装箱详解
    Java知多少(23)类的基本运行顺序
    Java知多少(22)方法重载
    Java知多少(21)this关键字详解
    Java知多少(20)变量的作用域
    Java知多少(19)访问修饰符(访问控制符)
  • 原文地址:https://www.cnblogs.com/xiaoyesoso/p/4265171.html
Copyright © 2020-2023  润新知