已阅读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中铁物资集团港澳有限公司招聘1人笔试(2020-2024年)参考题库附带答案详解(3卷合一)
- 2025中联重科春季校园招聘740人笔试历年难易错考点试卷带答案解析2套试卷
- 2025中国能建易普力公司招聘笔试历年常考点试题专练附带答案详解2套试卷
- 2025中国电力安徽淮南平圩发电有限责任公司应届毕业生招聘笔试历年常考点试题专练附带答案详解2套试卷
- 2025中国建筑材料工业地质勘查中心山西总队招聘(40人)笔试历年备考题库附带答案详解2套试卷
- 2025下半年江西萍乡市国盛控股发展集团有限公司招聘员工4人笔试历年难易错考点试卷带答案解析2套试卷
- 2025上汽集团大乘用车制造类岗位人才招募笔试历年常考点试题专练附带答案详解2套试卷
- 编外面试题目及答案
- 教育机构签合同
- 2025年高职综合素质题库及答案
- 2023年浙江省金华市义乌市高三下学期适应性考试(高考三模)物理试卷含答案
- 无痛支气管镜诊疗的麻醉管理
- Creo-7.0基础教程-配套课件
- 解除地质钻探合同书范本
- 招工登记表模板
- 路灯维护方案完整
- 2023年06月天津市便民专线服务中心招考聘用合同制员工笔试题库含答案解析
- 幼儿园绘本教学中师幼互动策略研究 论文
- 汽车维修保养服务单
- 300MW电气运行规程
- GA/T 1246-2015道路交叉口发光警示柱
评论
0/150
提交评论