#include <cstdio> #include <iostream> #include <cstring> #include <cstdlib> using namespace std; #ifdef ONLINE_JUDGE #define FINPUT(file) 0 #define FOUTPUT(file) 0 #else #define FINPUT(file) freopen(file,"r",stdin) #define FOUTPUT(file) freopen(file,"w",stdout) #endif struct Acm{ char name[110]; int score; int punish; }; int comp(const void *b,const void *a) { if(((Acm*)a)->score !=((Acm*)b)->score) return ((Acm*)a)->score - ((Acm*)b)->score; else if(((Acm*)a)->punish !=((Acm*)b)->punish) return ((Acm*)b)->punish - ((Acm*)a)->punish; else if (strcmp(((Acm*)a)->name, ((Acm*)b)->name)!=0) { return strcmp(((Acm*)b)->name, ((Acm*)a)->name); } } int main() { FINPUT("in.txt"); FOUTPUT("out.txt"); int n; while(cin>>n && n>=1 && n<=100) { Acm *a = new Acm[n]; for(int i=0;i<n;i++) { cin>>a[i].name>>a[i].score>>a[i].punish; } qsort(a,n,sizeof(Acm),comp); for(int i=0;i<n;i++) { cout<<a[i].name<<endl; } delete [] a; } return 0; }
九度 1339
时间: 2024-11-03 01:59:37