




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include#include#define NULL 0#define LEN sizeof(struct student)struct studentlong num;float score;struct student *next;int n;struct student *creat(void)/创建链表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 p2-next=p1;p2=p1;p1=(struct student *)malloc(LEN);scanf(%ld,%f,&p1-num,&p1-score);p2-next=NULL;return(head);/带回链表的头指针void print(struct student *head)/输出链表struct student *p;printf(nNow,there %d records are:n,n);p=head;if(head!=NULL)doprintf(%ld %5.1fn,p-num,p-score);p=p-next;while(p!=NULL);void averprintf(struct *head)/平均值输出struct student *p;float aver,sum=0,high=0,low=0;long num1;printf(nNow,the averge score is:n);p=head;if(head!=NULL)dosum=sum+p-score;p=p-next;while(p!=NULL);aver=sum/n;printf(%5.1fn,aver);void highprintf(struct student *p)/*求最高分*/ int high=p-score; long num1=p-num; do if (highscore) high=p-score; num1=p-num; p=p-next ;while (p!=NULL);printf(nThe highest score is:%d,and its number is:%ldn,high,num1);void lowprintf(struct student *p)/*求最低分*/ int low=p-score; long num1=p-num; doif (lowp-score) low=p-score; num1=p-num; p=p-next;while (p!=NULL);printf(nThe lowest score is:%d,and its number is:%ldn,low,num1);void sort(struct student *head)/学生成绩排序struct student *p1,*p2;float i;long t;printf(Students from low to high rankingn);p1=head;if(head=NULL)printf(it is blankn);elsewhile(p1!=NULL)p2=p1-next;while(p2!=NULL)if(p1-scorep2-score)i=p2-score;p2-score=p1-score;p1-score=i;t=p2-num;p2-num=p1-num;p1-num=p2-num;p2=p2-next;p1=p1-next;while(p1!=0)printf(%ld %5.1fn,head-num,p1-score);head-next;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(delete:%ldn,num);n=n-1;else printf(%ld not been found!n,num);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-numnum)if(head=p1)head=p0;else p2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;n=n+1;return(head);void main()struct student *head,*stu;long del_num;printf(input records:n);head=creat();lowprintf(head);/加入排序,最高分,最低分调用函数highprintf(head);averprintf(head);/删除节点操作print(head);sort(head);print(head);printf(ninput the deleted number:);scanf(%ld,&del_num);while(del_num!=0)head=del(head,del_num);print(head);printf(input the deleted number:);scanf(%ld,&del_num);/插入节点操作printf(ninputthe insertd record:);stu=(struct student *)malloc(LEN);scanf(%ld,%f,&stu-num,&stu-score);while(stu-
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- (2025年标准)配送站协议书
- 跨界融合模式创新-第2篇-洞察及研究
- 矿山沉降监测-洞察及研究
- (2025年标准)未经授权协议书
- 2025年先期采购目标协议书
- 2025年国企行政大楼综合管理后援团队笔试预测试题集
- 2025年中医馆转让协议书
- 2025年新干股和出资协议书
- (2025年标准)买车转赠协议书
- 2025年新质量损失考核协议书
- 异常工况安全处置管理制度(根据导则编写)
- DL-T5588-2021电力系统视频监控系统设计规程
- 全国食品安全风险监测参考值 2024年版
- 文昌顺发畜牧有限公司养猪场项目 环评报告
- 2024年华能甘肃能源开发有限公司招聘笔试参考题库含答案解析
- 助产士在产时并发症处理中的助产安全
- 单片机的看门狗
- 市场营销(第2版)课件全套 王永贵 第1-17章-市场与市场营销概述及发展-顾客营销学
- 高中数学 人教A版 必修一 《集合与常用逻辑用语》 1.1集合的概念
- 深圳某电厂锅炉维修改造施工组织设计-new(常用版)
- GB/T 4950-2021锌合金牺牲阳极
评论
0/150
提交评论