1083 List Grades (25 分)

大水题。。。完全没有(25)分题的样子。。。

struct Node
{
    string name;
    string id;
    int grade;
    bool operator<(const Node &W) const
    {
        return grade > W.grade;
    }
};
vector<Node> v;
int n;
int l,r;

int main()
{
    cin>>n;

    for(int i=0;i<n;i++)
    {
        string name,id;
        int grade;
        cin>>name>>id>>grade;
        v.pb({name,id,grade});
    }

    cin>>l>>r;

    vector<Node> res;
    for(auto t:v)
        if(t.grade >= l && t.grade <= r)
            res.pb(t);

    if(res.size() == 0) puts("NONE");
    else
    {
        sort(res.begin(),res.end());
        for(auto t:res)
            cout<<t.name<<' '<<t.id<<endl;
    }
    //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/fxh0707/p/14407430.html