[Cpp]/********************************* Date: * Author: SJF0115 * question: 9 degrees 1061 * questions: Performance Order * Source: http://ac.jobdu.com/problem.php? Pid = 1061 * result: AC * Meaning: * conclusion: * *********************************/# include <stdio. h> # include <stdlib. h> # include <string. h> typedef struct Student {char name [20]; int age; int grade;} Student; // sort int cmp (const void * a, const void * B) {struct Student * c = (Student *) a; struct Student * d = (Student *) B; if (c-> grade! = D-> grade) return c-> grade-d-> grade; else if (strcmp (c-> name, d-> name )! = 0) {return strcmp (c-> name, d-> name);} else {return c-> age-d-> age ;}} int main () {int n; Student student [1001]; // freopen ("C: \ Users \ SJF \ Desktop \ acm.txt", "r", stdin ); while (scanf ("% d", & n )! = EOF) {char name [20]; int age, grade; for (int I = 0; I <n; I ++) {scanf ("% s ", name); strcpy (student [I]. name, name); scanf ("% d", & age); student [I]. age = age; scanf ("% d \ n", & grade); student [I]. grade = grade;} // sort qsort (student, n, sizeof (student [0]), cmp); for (int I = 0; I <n; I ++) {printf ("% s % d \ n", student [I]. name, student [I]. age, student [I]. grade) ;}} return 0 ;} /*********************************** Date: 20 13-1-12 * Author: SJF0115 * question: 9 degrees 1061 * question: score sorting * Source: http://ac.jobdu.com/problem.php? Pid = 1061 * result: AC * Meaning: * conclusion: * *********************************/# include <stdio. h> # include <stdlib. h> # include <string. h> typedef struct Student {char name [20]; int age; int grade;} Student; // sort int cmp (const void * a, const void * B) {struct Student * c = (Student *) a; struct Student * d = (Student *) B; if (c-> grade! = D-> grade) return c-> grade-d-> grade; else if (strcmp (c-> name, d-> name )! = 0) {return strcmp (c-> name, d-> name);} else {return c-> age-d-> age ;}} int main () {int n; Student student [1001]; // freopen ("C: \ Users \ SJF \ Desktop \ acm.txt", "r", stdin ); while (scanf ("% d", & n )! = EOF) {char name [20]; int age, grade; for (int I = 0; I <n; I ++) {scanf ("% s ", name); strcpy (student [I]. name, name); scanf ("% d", & age); student [I]. age = age; scanf ("% d \ n", & grade); student [I]. grade = grade;} // sort qsort (student, n, sizeof (student [0]), cmp); for (int I = 0; I <n; I ++) {printf ("% s % d \ n", student [I]. name, student [I]. age, student [I]. grade) ;}} return 0 ;}