#include <stdio.h>
#include <stdlib.h>

enum {
    MAXNUM = 400,
    HISTOHIGH = 60,
    SEGLEN = 5,
    HISTONUM = (100/SEGLEN)+1
};

typedef struct {
	unsigned long num;
	char name[20];
	double score;
} StuRec;

StuRec students[MAXNUM];

int readrecs(FILE *fp, int limit, StuRec ss[]);

int scrcmp(const void *vp1, const void *vp2) {
    StuRec *p1 = (StuRec*)vp1, *p2 = (StuRec*)vp2;
    return p1->score > p2->score ? 1 :
           p1->score == p2->score ? 0 : -1;
}

int scr5cmp(const void *vp1, const void *vp2) {
    int n1 = ((StuRec*)vp1)->score, 
        n2 = ((StuRec*)vp2)->score;
    return n1/5 - n2/5;
}

int str1cmp(const void *vp1, const void *vp2) {
    char *p1 = ((StuRec*)vp1)->name, *p2 = ((StuRec*)vp2)->name;
    return strcmp(p1, p2);
}

int str1cmp1(const void *vp1, const void *vp2) {
    return strcmp(((StuRec*)vp1)->name, ((StuRec*)vp2)->name);
}



