#include <stdio.h> struct Student { float high; char sex; }; void fun(struct Student stu[]) { int i, j = 0; float s1 = 0, s2 = 0; for (i = 0; i < 5; i++) { if (stu[i].sex == 'm') { s1 += stu[i].high; j++; } else s2 += stu[i].high; } printf("男生平均身高%f\n女生平均身高%f\n", s1 / j, s2 / (5 - j)); } int main() { struct Student stu[5]; int i; for (i = 0; i < 5; i++) scanf("%f%c", &stu[i].high, &stu[i].sex); fun(stu); return 0; }