C语言菜鸟题目

来源:百度知道 编辑:UC知道 时间:2024/05/22 06:13:17
麻烦帮我做一下这道题啊,要完整的啊
因为我一点都不懂,谢谢各位了

一、实验目的

通过本实验掌握所学知识的综合应用能力。

二、实验内容

有10个学生,每个学生的数据包括学号、姓名、三门课的成绩。从键盘输入10个学生的数据,要求通过函数调用完成:

1、 输出三门课的总平均成绩。

2、 输出有一门或一门以上课程不及格的学生数据。

3、 输出每个学生按总分由高到低的排序结果。

4、 将原有数据和每个人的平均成绩存放在磁盘文件中。

提示:

结构体及变量可定义为:

struct student

{ char *name;

char *num;

int score[3];

int sum;

float ave;

} stu[10];
怎么没有人回答啊?

#include"stdio.h"
#include"stdlib.h"
#define N 3
struct student
{
char name[10];
char num[20];
int score[3];
int sum;
float ave;
struct student *next;
}stu[N];
struct student *creat()
{
int i;
struct student *h=NULL,*p;
for(i=0;i<N;i++)
{
p=(struct student *)malloc(sizeof(struct student));
printf("please input number,name,score1,score2,score3:\n");
scanf("%s %s %d %d %d",p->num,p->name,&p->score[0],&p->score[1],&p->score[2]);
/*警惕scanf("%s%s%d%d%d",stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);这样的错误*/
p->sum=p->score[0]+p->score[1]+p->score[2];
p->ave=((float)p->sum)/3;
p->next=h;
h=p;
}
return h;
}
voi