回复 6楼 我FEI
好的 我会试试的!谢谢!
改写了一下程序如下:
程序代码:
#include <stdio.h>
#define LEN 7
struct SCORE
{
char * km[LEN];
float gpa[LEN];
}first;
int main(void)
{
int i = 0;
float e = 0.0;
first.km[0] = "math";
first.km[1] = "chinese";
first.km[2] = "english";
first.km[3] = "c";
first.km[4] = "s";
first.km[5] = "jd";
first.km[6] ="physical";
printf("This is the first score in your college\n ");
printf("please fill in carefully!\n");
while (i < LEN)
{
switch (i)
{
case 0 : printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 1 : printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 2: printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 3: printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 4: printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 5: printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
case 6: printf("%s: ", first.km[i]);
scanf("%f", &first.gpa[i]);
break;
}
i++;
}
for (i = 0; i < LEN; i++)
e += first.gpa[i];
printf("%.1f\n", e / LEN);
return 0;
}









