#include #include #include typedef struct { char name[30]; float irritation; char note[30]; } SHREK; int compar(const void *a1, const void *b1) { SHREK *a=(SHREK*)a1; SHREK *b=(SHREK*)b1; if ( (a->irritation) > (b->irritation) ) return -1; else if ( (a->irritation) < (b->irritation) ) return 1; else return (-1)*strcmp(a->name, b->name); } int main(int argc, char **argv) { char sor[1000], *token; SHREK shreks[30]; int i, db=0; while( fgets(sor,1000,stdin) != NULL ) { token=strtok(sor,";"); strcpy(shreks[db].name, token); token=strtok(NULL,";"); shreks[db].irritation=atof(token); token=strtok(NULL,"\n"); strcpy(shreks[db].note, token); db++; } qsort(shreks, db, sizeof(SHREK), compar); for(i=0; i<3; i++) printf("%s (%.1f): %s\n", shreks[i].name, shreks[i].irritation, shreks[i].note); return 0; }