解决一个关于结构体的问题
程序代码:
#include <stdio.h> struct student { char num[10]; char name[10]; float score[4]; }; void main() { struct student stu[5]={ {"201060001","Zhao",85,86,88}, {"201060002","Qian",87,88,89}, {"201060003","Sun", 91,92,93}, {"201060004","Li", 92,91,93}, {"201060005","Wang",94,95,99}}; int i; float max=0; printf("==========================================\n"); printf(" Num Name Ave\n"); for(i=0;i<5;i++) {stu[i].score[3]=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0; printf("%s %s %5.1f\n", stu[i].num,stu[i].name,stu[i].score[3]);} for(i=0;i<4;i++) { if(stu[i].score[3]<stu[i++].score[3]) max=stu[i++].score;i++; printf(" Num Name score1 score2 score3 Ave\n"); printf("%s %s %5.1f %5.1f %5.1f %5.1f\n", stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3]); } printf("==========================================\n"); }我想将最高平均分输出,并输出对应的学号、姓名及三门课程,请问这个程序怎么改正啊!
[ 本帖最后由 宇智波曌 于 2011-5-24 23:17 编辑 ]