设计思路:
- 似乎又是一道排序题,处理好排序即可
编译器:C (gcc)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct score {
char name[21];
int program;
int mid;
int final;
int total;
};
int cmp_sort_total(const void *a, const void *b)
{
struct score *s1 = (struct score *)a;
struct score *s2 = (struct score *)b;
if (s2->total - s1->total)
return s2->total - s1->total;
return strcmp(s1->name, s2->name);
}
int cmp_sort_name(const void *a