1. 程式人生 > >PAT (Advanced Level) Practice 1083 List Grades (25 分)

PAT (Advanced Level) Practice 1083 List Grades (25 分)

#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

const int N=1e3+5;

struct People
{
    char name[15],id[15];
    int grade;
}p[N];

vector<int> G[N];

int main()
{
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf(
"%s%s%d",p[i].name,p[i].id,&p[i].grade); G[p[i].grade].push_back(i); } int l,r; scanf("%d%d",&l,&r); int f=0; for(int i=r;i>=l;i--) for(int j=0;j<G[i].size();j++) { int v=G[i][j]; f=1; printf("%s %s\n",p[
v].name,p[v].id); } if(!f) puts("NONE"); return 0; }