//#include "stdafx.h"//If the vc++6.0, with this line.
#include "
stdio.h"
#include "
stdlib.h"
int main(void){
int N,i,fm,tmp,(*p)[3];
while(1){
printf("Input N(int 0<N)...\nN=");
if(scanf("%d",&N),N>0)
break;
printf("Error, redo: ");
}
if((p=(int (*)[3])malloc(sizeof(int)*3*N))==NULL){
printf("Failed to create the array...\n");
exit(0);
}
printf("Please enter the 3 grades of every student...\n");
for(i=0;i<N;i++){
printf("STU%d:\t",i+1);
scanf("%d%d%d",p[i],p[i]+1,p[i]+2);
}
printf("\nStudent\tAverage\tTotal\n---------------------\n");
for(fm=p[0][0]+p[0][1]+p[0][2],i=0;i<N;i++){
printf("STU%d\t%.2f\t%d\n",i+1,tmp/3.0,tmp=p[i][0]+p[i][1]+p[i][2]);
if(fm<tmp)
fm=tmp;
}
free(p);
printf("The highest total score is %d\n",fm);
return 0;
}