求C语言编程代码

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:16:40
输入n(n≤30)个学生的姓名及某课考试成绩。编程实现:
1.计算并输出全班的平均分。
2.输出前六名学生的姓名及成绩。

谢谢啦

struct stu
{
char name[30];
int score;
int n;
}student[S];
int sum;

int input()
{
int i;
for(i=0;i<n;i++)
{printf("The name of Student %d:",i+1);
scanf("%s",&student[i].name);
printf("The score of Student %d:",i+1);
scanf("%d",&student[i].score);
sum+=student[i].score;
}
}

void theSix()
{
int i;
int max;
int maxid;
int found;
i=0;
max=student[0].score-1;
maxid=0;
found=0;
while(found<6)
{
for(i=0;i<n;i++)
{if(student[i].score>max) {
max=student[i].score;
maxid=i;}
}
printf("No.%d:%s,his score is %d\n",found+1,student[maxid].name,max);
max=0;
student[maxid].score=0;
found++;}
}

int main(