zoukankan      html  css  js  c++  java
  • PAT 1083

     1 #include <vector>
     2 #include <algorithm>
     3 #include <string>
     4 #include <iostream>
     5 
     6 using namespace std;
     7 
     8 struct Student{
     9     int grade;
    10     string name;
    11     string id;
    12 };
    13 
    14 bool compare(const Student &s1, const Student &s2){
    15     return s1.grade > s2.grade;
    16 }
    17 
    18 int main(){
    19     int N;
    20     cin >> N;
    21 
    22     vector<Student> students;
    23 
    24     for (int i = 0; i < N; i++){
    25         Student s;
    26         cin >> s.name >> s.id >> s.grade;
    27 
    28         students.push_back(s);
    29     }
    30 
    31     int low, high;
    32     cin >> low >> high;
    33 
    34     sort(students.begin(), students.end(), compare);
    35     bool none = true;
    36     for (int i = 0; i < students.size(); i++){
    37         if (students[i].grade < low)
    38             break;
    39         if (students[i].grade > high)
    40             continue;
    41 
    42         none = false;
    43         cout << students[i].name << " " << students[i].id << endl;
    44     }
    45 
    46     if (none)
    47         cout << "NONE" << endl;
    48 
    49     return 0;
    50 }
  • 相关阅读:
    My first blog!
    Elasticsearch安装 + Head插件安装 + Bigdesk插件安装
    泛型-反射-注解
    JFinal自定义FreeMarker标签
    Hadoop集群中节点角色定义
    HBase
    MapReduce
    HDFS
    Hadoop基本概念
    HTTP浅析
  • 原文地址:https://www.cnblogs.com/EpisodeXI/p/4084073.html
Copyright © 2011-2022 走看看