用C语言链表编写学生成绩管理系统

本代码供读者学习使用,请不要随意转载。

一、设计题目:学生成绩管理系统

二、目的与要求
每位学生记录包含有学号、姓名、性别、出生日期、三门功课的成绩(高等数学、大学英语、C语言)、总分和平均分
系统菜单:
(1)录入学生记录
(2)添加学生记录
(3)删除学生记录
(4)修改学生记录(要求输入密码)
(5)查找学生记录(按学号、按姓名)
(6)按总分对记录进行降序排列
(7)将当前结果显示或打印,重新保存进数据文件中
(8)输出所有学生信息
(9)计算班级平均分
(10)修改管理员密码(未保存至文件,程序关闭后失效)
(11)C语言挂科人数
(0)结束程序

#include<stdio.h>
#include<stdlib.h> 
#include<string.h>
#include<malloc.h>
#include<math.h>
#define LEN sizeof(struct student)
 struct student
{
	struct student *next;
	long num;
	char name[8];
	char sex[4];
	int year;
	int month;
	int day;
	float c;
	float math;
	float eng;
	float sum;
};

int n;
struct student * creat()          //建立基础的学生信息库 
{
	struct student * head,*p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	printf("输入学生的学号为0时,停止录入.\n");
        printf("请输入学生学号:");
		scanf("%ld",&p1->num);
		if(p1->num!=0)
		{
		printf("请输入学生姓名:");scanf("%s",p1->name);
		printf("请输入学生性别:");scanf("%s",p1->sex); 
	 printf("请输入学生生日:\n");
	 printf("年:");scanf("%d",&p1->year);
	 printf("月:");scanf("%d",&p1->month);
	 printf("日:");scanf("%d",&p1->day);
	    printf("c语言:");scanf("%f",&p1->c);
	    printf("高数:");scanf("%f",&p1->math);
	    printf("英语:");scanf("%f",&p1->eng);
	    p1->sum=p1->c+p1->eng+p1->math;
		printf("\n");
	}
	while(p1->num!=0)
	{
		n=n+1;
		if(n==1)
		{
			head=p1;
		}
		else
		{
			p2->next=p1;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
            printf("请输入学生学号:");
	scanf("%ld",&p1->num);
	if(p1->num!=0)
	{
	printf("请输入学生姓名:");scanf("%s",p1->name);
	printf("请输入学生性别:");scanf("%s",p1->sex);
	 printf("请输入学生生日:\n");
	 printf("年:");scanf("%d",&p1->year);
	 printf("月:");scanf("%d",&p1->month);
	 printf("日:");scanf("%d",&p1->day);
	    printf("c语言:");scanf("%f",&p1->c);
	    printf("高数:");scanf("%f",&p1->math);
	    printf("英语:");scanf("%f",&p1->eng);
	    p1->sum=p1->c+p1->eng+p1->math;
		printf("\n");
	}
	}
     p2->next=NULL;
	return head;
}

struct student * del(struct student *head,long num) //删除学生信息 
{
	struct student  *p1,*p2;
	if(head==NULL)
	{
		printf("\nlist null!\n");
		return head;
	}
	p1=head;
	while(num!=p1->num&&p1->next!=NULL)
	{
		p2=p1;p1=p1->next;
	}
		if(num==p1->num)
		{
			if(p1==head)
				head=p1->next;
			else
				p2->next=p1->next;
			printf("你删除的学生信息为:\n");
			printf("学号:%ld\n",p1->num);
					printf("姓名:%s\n",p1->name);
					printf("性别:%s\n",p1->sex);
					printf("生日:\n");
					printf("年:%d\n",p1->year);
					printf("月:%d\n",p1->month);
					printf("日:%d\n",p1->day);
					printf("c语言:%5.2f\n",p1->c);
					printf("高数:%5.2f\n",p1->math);
					printf("英语:%5.2f\n",p1->eng);
					p1->sum=p1->c+p1->math+p1->eng;
			        printf("总分:%5.2f\n",p1->sum);
					printf("\n");
			n=n-1;
		}
			else
				printf("输入有误!\n");
	    return head;
}

struct student * insert (struct student *head,struct student *stud) //添加学生信息 
{
	struct student * p0,*p1,*p2;
	p1=head;
	p0=stud;
	if(head==NULL)
	{
		head=p0;
		p0->next=NULL;
	}
	else
		while((p0->num>p1->num)&&(p1->next!=NULL))
		{
			p2=p1;
			p1=p1->next;
		}
	
  • 107
    点赞
  • 731
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 23
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

white_poland

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值