简单学生信息管理系统

简单学生信息管理系统

ID:24842088

大小:72.00 KB

页数:4页

时间:2018-11-16

简单学生信息管理系统_第1页
简单学生信息管理系统_第2页
简单学生信息管理系统_第3页
简单学生信息管理系统_第4页
资源描述:

《简单学生信息管理系统》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、简单学生信息管理系统用c语言实现学生信息单向链表,有建立,插入,删除,打印显示功能,如果输入是同一个学生的,信息将更新,不同学生按学号由小到大排列。#include#include#defineNULL0#defineLENsizeof(structstudent)structstudent{longnum;floatscore;structstudent*next;};intn;voidswap(float*p1,float*p0){*p1=*p0;}structstudent*creat(){structstud

2、ent*head;structstudent*p1,*p2;n=0;p1=p2=(structstudent*)malloc(LEN);scanf("%ld,%f",&p1->num,&p1->score);head=NULL;while(p1->num!=0){n=n+1;if(n==1)head=p1;else{if(p1->num==p2->num){p2->score=p1->score;n--;gotoend;}elsep2->next=p1;}p2=p1;p1=(structstudent*)malloc(LEN);end:scanf("%l

3、d,%f",&p1->num,&p1->score);}p2->next=NULL;return(head);}voidprint(structstudent*head){structstudent*p;printf("现在系统有%d个学生",n);p=head;if(head!=NULL)do{printf("%ld%5.1f",p->num,p->score);p=p->next;}while(p!=NULL);}structstudent*del(structstudent*head,longnum){structstudent*p1,

4、*p2;if(head==NULL){printf("listnull!");gotoend;}p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1==head)head=p1->next;elsep2->next=p1->next;printf("学号为:%ld的学生被删除了",num);n=n-1;}elseprintf("系统没有学号为%ld的学生!",num);end:return(head);}structstu

5、dent*insert(structstudent*head,structstudent*stud){structstudent*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;}if(p0->num==p1->num){p1->score=p0->score;free(p0);gotoend;}else{if(p0->numnum)

6、{if(head==p1)head=p0;elsep2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}}n=n+1;end:return(head);}main(){structstudent*head,*stu;longdel_num;printf("输入学生:学号,成绩(输入0,0时结束)");head=creat();print(head);printf("输入要删除的学生的学号:");scanf("%ld",&del_num);while(del_num!=0){head=d

7、el(head,del_num);print(head);printf("输入要删除的学生的学号:(输入0时退出)");scanf("%ld",&del_num);}print(head);printf("插入一个学生信息:学号,成绩(输入0,0时结束)");stu=(structstudent*)malloc(LEN);scanf("%ld,%f",&stu->num,&stu->score);while(stu->num!=0){head=insert(head,stu);print(head);printf("插入一个学生信息:学号,成

8、绩(输入0,0时结束)");stu=(structstudent*)malloc

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。