1,项目要求
链表A,每个节点存放一个新的链表B1,B2,B3,B4,B5的头结点。
场景:一个年级,相当链表A
该年级5个班,每个班5个人,相当于链表B1–B5
做一个学生成绩管理系统
学生成绩有语文 数学 英语
功能: 录入成绩 找最三科总分的最高分 最低分 算出平均分
2,源代码
main函数
int main()
{
printf("##### welcome to the system ####\n");
int c_num;
int s_num;
struct Class *head;
printf("please input the number of Class\n");
scanf("%d",&c_num);
printf("please input the number of the Class student\n");
scanf("%d",&s_num);
head = creatClass(head, c_num, s_num);
printMessage(head, c_num, s_num);
getMax(head, c_num, s_num);
getMin(head, c_num, s_num);
getAvge(head, c_num, s_num);
system("pause");
return 0;
}
创建学生结构体
struct Student{
int xuehao;
int chinese;
int math;
int english;
int sum;
double avge;
struct student *next;
};
创建班级结构体
struct Class{
struct Student *stuhead;
struct Class *next;
int Classnum;
};
使用头插法建立学生链表
struct Student* insertStuMessage(struct Student *head,struct Student *new)
{
if(head == NULL){
head = new;
}
else
{
new->next = head;
head = new;
}
return head;
}
struct Student* creatStudent(struct Student *head, int snum, int cnum)
{
int i;
int num =