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 }
  • 相关阅读:
    vue2.0开发聊天程序(八) 初步完成
    王下邀月熊_Chevalier的前端每周清单系列文章索引
    将HTML页面转换为PDF文件并导出
    二维码活码管理系统
    前端眼里的docker
    这些好玩的例子,希望你也能喜欢
    如何实现swipe、tap、longTap等自定义事件
    基于 HTML5 Canvas 的交互式地铁线路图
    【php学习】时间函数
    页面瀑布流布局的实现 javascript+css
  • 原文地址:https://www.cnblogs.com/xiaoyesoso/p/4265171.html
Copyright © 2011-2022 走看看