c语言链表成绩管理系统排序,【C项目】 文件,结构体,链表,排序, 学生信息管理系统...

1、密码登录;

2、通过键盘输入学生信息,包括学生学号、姓名、成绩;

3、将输入的信息保存到指定文件中;

4、从文件中读取学生信息;

5、显示全部学生信息;

6、按学生总分进行降序排序;

7、删除学生信息;

8、查找学生信息,可以通过学号查找,也可以通过姓名查找;

9、统计学生信息,统计出最高分和学生人数;

10、退出系统;

源代码:chunli@Linux:~$ cat main.c

#include

#include

#include

struct student

{

char num[9];

char name[9];

int scorem;

int scoree;

int scorec;

int sum;

struct student *next;

};

struct student *creat(struct student *p)//创建链表

{

struct student *p1 = NULL;

p1 = (struct student*)malloc(sizeof (struct student));

p -> next = p1;

p1 -> next = NULL;

printf("请输入要添加的学生的信息\n");

printf("学号:");scanf("%s",p1 -> num);

printf("姓名: ");scanf("%s",p1 -> name);

printf("数学成绩:");scanf("%d",&p1 -> scorem);

printf("英语成绩:"); scanf("%d",&p1 -> scoree);

printf("C语言成绩:");scanf("%d",&p1 -> scorec);

p1 -> sum = 0;

p1 -> sum = p1 -> scorem + p1 -> scorec + p1 -> scoree;

printf("总分:%d",p1 -> sum);

return p1;

}

void save1(struct student *p)//将链表从内存保存到文件中

{

FILE *fp;

if ((fp = fopen("student_system.txt","ab+")) == NULL)

printf("创建失败!\n");

while(p != NULL)

{

fwrite(p,sizeof(struct student),1,fp);

p = p -> next;

}

fclose(fp);

printf("保存成功!\n");

}

void save2(struct student *p)//将以变动的链表信息存入到文件中

{

FILE *fp;

if ((fp = fopen("student_system.txt","wb")) == NULL)

printf("创建失败!\n");

while(p != NULL)

{

fwrite(p,sizeof(struct student),1,fp);

p = p -> next;

}

fclose(fp);

}

struct student *read()//把文件中的数据读到链表中

{

FILE *fp;

struct student *head=NULL,*p1=NULL,*p2=NULL;

if ((fp=fopen ("student_system.txt","rb+"))==NULL)

{

printf ("读取时,文件打开失败!\n");

return NULL;

}

head=p1=(struct student *)malloc (sizeof (struct student ));

while (fp != NULL)

{

if (fread(p1,sizeof (struct student ),1,fp) != 1)break;

p1 -> next = (struct student *)malloc (sizeof (struct student ));

p2= p1;

p1= p1 -> next;

}

p2->next = NULL;

fclose (fp);

return head;

}

struct student *input()//添加函数

{

char ch;

struct student *p = NULL,*head=NULL;

head=p = (struct student*)malloc(sizeof(struct student));

p-> next = NULL;

printf("请输入要添加的学生的信息\n");

printf("学号:"); scanf("%s",p -> num);

printf("姓名: "); scanf("%s",p -> name);

printf("数学成绩:");scanf("%d",&p -> scorem);

printf("英语成绩:");scanf("%d",&p -> scoree);

printf("C语言成绩:");scanf("%d",&p -> scorec);

p -> sum = 0;

p -> su

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值