创建动态链表设计简单学生成绩信息管理系统

本文介绍了如何使用C语言通过尾插法创建动态链表,构建一个简单的学生成绩信息管理系统。系统包括学生链表和班级链表的创建,以及查找班级总分、平均分最高和最低的学生等功能。文章详细讲解了结构体定义、链表插入、学生信息查询及打印等操作,并提供了完整的代码实现和测试案例。
摘要由CSDN通过智能技术生成

一、尾插法创建动态链表
二、(1)学生链表;(2)班级链表

1.1学生结构体

struct Student
{
   
        int Chinese_score;
        int Math_score;
        int English_score;
        int total_three_score;
        float ave_three_score;
        char *name;
        struct Student *next;
};

1.2尾插法创建学生动态链表

struct Student *insertStudentBehindHead(struct Student *head, struct Student *new)
{
   
        struct Student *p = head;
        if (p == NULL){
   
                head = new;
                return head;
        }

        while(p->next != NULL){
   
                p = p->next;
        }
        p->next = new;

        return head;
}

struct Student *createStudentLinkBehindHead(struct Class *head1, struct Student *head2)
{
   
        struct Student *new = NULL;
        int j;

        for(j = 0; j < head1->num_stu; j++){
   
                new = (struct Student *)malloc(sizeof(struct Student));
                new->name = (char *)malloc(128);

                getchar();
                printf("请输入第%d个学生姓名:\n", (j+1));
                scanf("%s", new->name);
                printf("请输入语文成绩:\n");
                scanf("%d", &(new->Chinese_score));
                printf("请输入数学成绩:\n");
                scanf("%d", &(new->Math_score));
                printf("请输入英语成绩:\n");
                scanf("%d", &(new->English_score));

                new->total_three_score = new->Chinese_score + new->Math_score + new->English_score;
                new->ave_three_score = (float)new->total_three_score/3;

                head2 = insertStudentBehindHead(head2, new);

        }

        return head2;
}

2.1班级结构体

struct Class
{
   
        int num_stu;
        int grade;
        int total_Chinese;
        int total_Math;
        int total_English;
        float ave_Chinese;
        float ave_Math;
        float ave_English;
        struct Student *stu_score;
        struct Student *stu_MaxTotalScore;
        struct Student *stu_MinTotalScore;
        struct Class *next;
};

2.2尾插法创建班级链表

struct Class *insertClassBehindHead(struct Class *head, struct Class *new)
{
   
        struct Class *p = head;
        if (p == NULL){
   
                head = new;
                return head;
        }

        while(p->next != NULL){
   
                p = p->next;
        }

        p->next = new;

        return head;
}

struct Class *createClassLinkBehindHead(struct Class *head1, struct Student *head2)
{
   
        struct Class *new1 = NULL;
        struct Student *pnew = NULL;
        struct Student *pnew1 = NULL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值