#include <stdio.h>
#include<stdlib.h>
#include<string.h>
main() {
FILE *fp;
char buff[255],score[60];
int grade=0;
float x=0;
fp = fopen("grade.txt", "r");
printf("Sorting by average:\n");
while (!feof (fp)){
fscanf(fp, "%s", buff);
printf("%s", buff );
int i;
for (i=1;i<=3;i++){
fscanf(fp, "%d", &grade);
printf(" %d",grade);
x=x+grade;
}
x=x/3;
printf(" %.1f",x);
fscanf(x,"%s",score);
x=0;
printf("\n");
}
fclose(fp);
}