C语言的一道小题,请各位帮帮忙!

来源:百度知道 编辑:UC知道 时间:2024/06/18 14:55:45
2.编写程序,在已有的学生信息(学号、姓名、年龄、成绩)中,以初始化方式存入8个学生的信息,将每位学生年龄增加1岁,计算并输出平均成绩,找出年龄在20岁以上的学生并输出。

#include <iostrema.h>
struct student
{
int num;
char name[18];
int age;
float score;
}stu[8]={
//初始化自己写一下
};
void main()
{
int i;
float aver_score=0;
for(i=0;i<8;i++)
{
stu[i].age++;
aver_score+=stu[i].score;
if(stu[i].age>20)
printf("%s\n",stu[i].name);
}
aver_score/=8;
printf("%f\n",aver_scoer);
}