#include<stdio.h>
main()
{
struct score
{float score[3];
float average;
}stu[5];
int count;
for(count=0;count<5;count++)
{printf("Please input the scores of NO.%d student: ",count+1);
scanf("%.2f,%.2f,%.2f",&stu[count].score[0],&stu[count].score[1],&stu[count].score[2]);
}
for(count=0;count<5;count++)
stu[count].average=(stu[count].score[0]+stu[count].score[1]+stu[count].score[2])/3.0;
for(count=0;count<5;count++)
printf("\nThe average score of NO.%d is %.2f.\n",count+1,stu[count].average);
}
不知道可以不?
#include<stdio.h>
main()
{
struct score
{float score[3];
float average;
}stu[5];
struct score *p;
for(p=stu;p<stu+5;p++)
{printf("Please input the scores:\n");
scanf("%.2f,%.2f,%.2f",&p->score[0],&p->score[1],&p->score[2]);
}
for(p=stu;p<stu+5;p++)
p->average=(p->score[0]+p->.score[1]+p->.score[2])/3.0;
for(p=stu;p<stu+5;p++)
printf("\nThe average score is \n",p->average);
}
[[it] 本帖最后由 scheelite 于 2008-11-5 15:43 编辑 [/it]]