我再TC上试过的,绝对正确!可以自己把班里同学的人数改一改~~
#include
#define NUM 5 //(班里的人数)
typedef struct{
int score1;
int score2;
char name[10];
int final;
int ave;
}Student;
void input(Student stu[]);
void output(Student stu[]);
int main(){
Student stu[NUM];
int i;
input(stu);
output(stu);
}
void input(Student stu[]){
int i;
int better=0,good=0;
printf("Please enter students'name and scores:\n");
for(i=0;i
stu[i].final=stu[i].score1+stu[i].score2;
stu[i].ave=stu[i].final/2;
if(stu[i].ave>=85) better ++;
if(stu[i].ave>=60&&stu[i].ave<85) good++;
}
printf("the number of better and good is%5d %5d\n",better,good);
}
void output(Student stu[]){
int i;
printf("The final and average of every student is :\n");
printf("NAME FINAL AVE\n");
for(i=0;i
}