1025 PAT Ranking (25 分)

#include 
#include 
#include 

using namespace std;

typedef struct Student {
   char id[15];
   int score;
   int location_number;
   int local_rank;
}Student;

bool cmp(Student a, Student b) {
   if(a.score != b.score) return a.score > b.score;
   else return strcmp(a.id, b.id) < 0;
}

int main(int argc, char *argv[]) {
   Student stu[30010];
   
   int n, k, num = 0;
   scanf("%d", &n);
   for(int i=1; i<=n; i++) {
       scanf("%d", &k);
       for(int j=0; j0 && stu[i].score != stu[i-1].score) r = i+1;
       printf("%s ", stu[i].id);
       printf("%d %d %d\n", r, stu[i].location_number, stu[i].local_rank);
   }
   
}

你可能感兴趣的:(1025 PAT Ranking (25 分))