PAT (Advanced Level) 1083. List Grades (25)

Posted Fighting Heart

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1083. List Grades (25)相关的知识,希望对你有一定的参考价值。

简单排序。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

struct X
{
    string s;
    string c;
    int g;
}p[100000];
int n;

bool cmp(const X&a,const X&b)
{
    return a.g>b.g;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>p[i].s>>p[i].c>>p[i].g;
    sort(p+1,p+1+n,cmp);

    int flag=0;
    int L,U; scanf("%d%d",&L,&U);
    for(int i=1;i<=n;i++)
    {
        if(p[i].g>=L&&p[i].g<=U)
        {
            cout<<p[i].s<<" "<<p[i].c<<endl;
            flag=1;
        }
    }
    if(flag==0) printf("NONE\n");
    return 0;
}

 

以上是关于PAT (Advanced Level) 1083. List Grades (25)的主要内容,如果未能解决你的问题,请参考以下文章

PAT (Advanced Level) 1025. PAT Ranking (25)

PAT Advanced Level 1044

PAT Advanced Level 1043

PAT Advanced Level 1079

PAT Advanced Level 1095

PAT Advanced Level 1038