zoukankan      html  css  js  c++  java
  • HDU 1236

    水题~~但我做了很久;

    题意:是中国人都懂了

    思路:结构体排序;

    以后要多用用重定义的排序手段,!!!!!多用!!多用!!多用!!

     1 #include<iostream>
     2 #include<algorithm>
     3 #include<string>
     4 using namespace std;
     5 int grade[15];
     6 struct result{
     7     string num;
     8     double tot;
     9 }p[1050];
    10 bool cmp(result a,result b)
    11 {
    12     if(a.tot==b.tot)
    13         return a.num < b.num;
    14     return a.tot > b.tot;
    15 }
    16 int main()
    17 {
    18     int n,m,low,t;
    19     while(cin >> n && n){
    20         cin >> m >> low;
    21          for(int i=1;i<=m;++i)
    22              cin >> grade[i];
    23         string str;int x,y,sum=0;
    24                 t=0;
    25         for(int i=0;i<n;++i){
    26             cin >> str;cin >> x;
    27             for(int j=0;j<x;++j){
    28                 cin >> y;sum+=grade[y];
    29             }
    30             if(sum>=low){
    31                 p[t].num=str;p[t].tot=sum;
    32                 ++t;
    33             }
    34             sum=0;
    35         }
    36         sort(p,p+t,cmp);
    37             cout << t << endl;
    38         for(int i=0;i<t;++i)
    39             cout << p[i].num << " " << p[i].tot << endl;
    40     }
    41 }
  • 相关阅读:
    第六章 条件处理
    VS2019配置MKL教程(Windows)
    攻防世界--srm-50
    攻防世界--The_Maya_Society
    攻防世界--re1-100
    BUUCTF--findit
    凯撒加密与解密实现
    BUUCTF--rsa
    正则表达式
    PyQuery详解
  • 原文地址:https://www.cnblogs.com/sasuke-/p/5147791.html
Copyright © 2011-2022 走看看