#include#include #include #define AS 20 #define ZX 15 #define CSIZE 4 struct aa { char q[AS]; char w[ZX]; }; struct student { struct aa name; float grade[AS]; float e[AS]; }; void san(void); void qq(struct student x[],int h); void ww(struct student f[]); struct student s[CSIZE]; int main(void) { int c = 0; int p = 0; while (p < CSIZE) { printf("请输入学生姓:"); gets_s(s[p].name.q, AS - 1); printf("请输入学生名:"); gets_s(s[p].name.w, ZX - 1); printf("请输入学生分数:"); while ((c = scanf_s("%f,%f,%f", &s[p].grade[0], &s[p].grade[1], &s[p].grade[2])) != 3) { printf("分数输入错误,请重新输入:"); } san(); qq(s,p); p++; } ww(s); return 0; } void san(void) { while (getchar() != 'n') continue; } void qq(struct student x[],int h) { float a = 0; a = x[h].grade[0] + x[h].grade[1] + x[h].grade[2]; x[h].e[0] = a/3; printf("3门平均分数%.3fn", x[h].e[0]); } void ww(struct student f[]) { float s = 0; float j = 0; for (int y = 0; y < CSIZE; y++) { printf("姓名:%s%sn", f[y].name.q, f[y].name.w); printf("3门分数:%.2f %.2f %.2fn", f[y].grade[0], f[y].grade[1], f[y].grade[2]); printf("3门平均分数:%.2fn", f[y].e[0]); s = f[y].e[0] + s; } j = s / CSIZE; printf("班级平均分数:%f", j); }



