免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本文档系作者精心整理编辑,实用价值高。简单学生信息管理系统用c语言实现学生信息单向链表,有建立,插入,删除,打印显示功能,如果输入是同一个学生的,信息将更新,不同学生按学号由小到大排列。#include stdio.h#include malloc.h#define NULL 0#define LEN sizeof(struct student) struct student long num; float score; struct student *next; ; int n; void swap(float *p1,float *p0)*p1=*p0;struct student *creat() struct student *head; struct student *p1,*p2; n=0;p1=p2=( struct student*) 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-;goto end; else p2-next=p1; p2=p1; p1=(struct student*)malloc(LEN);end: scanf(%ld,%f,p1-num,p1-score); p2-next=NULL; return(head);void print(struct student *head) struct student *p; printf(n现在系统有 %d 个学生n,n); p=head; if(head!=NULL) do printf(%ld %5.1fn,p-num,p-score); p=p-next; while(p!=NULL); struct student *del(struct student *head,long num) struct student *p1,*p2; if (head=NULL)printf(nlist null!n);goto end; 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(学号为:%ld的学生被删除了n,num); n=n-1; else printf(系统没有学号为%ld的学生!n,num); end: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; elsewhile(p0-nump1-num) (p1-next!=NULL)p2=p1; p1=p1-next; if(p0-num=p1-num)p1-score=p0-score;free(p0);goto end;else if(p0-nump1-num) if(head=p1) head=p0; else p2-next=p0; p0-next=p1; else p1-next=p0; p0-next=NULL; n=n+1; end: return(head);main() struct student *head,*stu; long del_num; printf(输入学生:学号,成绩(输入0,0时结束)n); head=creat(); print(head); printf(n输入要删除的学生的学号:); scanf(%ld,del_num); while(del_num!=0) head=del(head,del_num); print(head); printf(n输入要删除的学生的学号:(输入0时退出)); scanf(%ld,del_num); print(head); printf(n插入一个学生信息:学号,成绩(输入0,0时结束)); stu=(struct student *)malloc(LEN); scanf(%ld,%f,stu-num,stu-score); while(stu-num!=0) head=insert(head,stu); print(head); printf(n插入一个学生信息:学号,成绩(输入0,0时结束)); stu=(struc
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 城市医疗救助课件
- 创伤愈合课件
- 超市学习汇报课件
- 传输线变压器课件
- 超市卫生培训课件
- 彩色糖果小班课件
- 陈涉世家获奖课件
- 村社区安全培训课件
- 厨师培训内容课件
- 年加工铜丝3000吨项目环境影响报告表
- 2026人教版六年级上册数学第三单元《分数除法》基础过关自测卷(含答案)
- 第7课 神奇的世界 第1课时 课件(内嵌视频)2026-2027学年道德与法治四年级上册统编版
- 2026年四川省国有企业综合招聘笔试备考习题
- 【答案】《信息安全技术》(战略支援部队信息工程大学)章节作业中国大学慕课答案
- 学堂在线 组织行为与管理 章节测试答案
- 2025年马原期末考试题库附完整答案详解(真题)
- 2025年海光信息物理实现笔试及答案
- 2026航天科工十院校园招聘(公共基础知识)综合能力测试题附答案解析
- 中国航天科工校招试题及答案
- 1.1公有制为主体多种所有制经济共同发展课件-2025-2026学年高中政治统编版必修二经 济与社会
- 旅馆顾客财物管理制度
评论
0/150
提交评论