链表实现学生系统

链表实现学生系统

ID:42112922

大小:228.00 KB

页数:5页

时间:2019-09-07

链表实现学生系统_第1页
链表实现学生系统_第2页
链表实现学生系统_第3页
链表实现学生系统_第4页
链表实现学生系统_第5页
资源描述:

《链表实现学生系统》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、姓名:许江华双向循坏链作业学号:S130101200#include#include#defineNULLO#defineLENsizeof(structstudent)structstudent{longnum;floatscore;structstudent*next,*prior;};intn;structstudent*creat(void){structstudent*head;structstudent*pl,*p2;n=0;pl=p2=(structstudent*)malloc(

2、LEN);scanf("%ld,%f&p1->num,&p1->score);head二NULL;while(p1->num!=0){n=n+l;if(n==1){head=p1;head->next=head;head->prior=head;}else{p2->next=p1;pl->prior=p2;p1->next=head;head->prior=p1;}p2=pl;p

3、=(structstudent*)mal!oc(LEN);scanf("%]d,%f',&pl->num,&p1->score);}return(head

4、);voidprint(structstudent*head){structstudent*p;printf(HNow,these%drecordare:n,n);p=head;if((head!=NULL)&&(n>0))do{printf(nnum%ld,score%5・1frf;p・>num,p・>scoi・e);p=p->next;}while((p!=head));}structstudent*dcl(structstudent*head,longnum){structstudent*pl,*p2;if(head

5、==NULL){printf("空表");retumhead;)pl=head;while((num!=p1->num)&&(p1->next!=head)){p2=pl;pl=pl->next;}if(num==p1->num)(if(pl==head){p1->next->prior=p1->prior;p1->prior->next=p1->next;head=p1->next;)else{p1->prior->next=p1・>next;p1->next->prior=p1->prior;}//printf("delete:

6、%ld°,num);n=n-l;}elseprintf(Hld%notbeenfondH,num);return(head);structstudent*insert(structstudent*head,structstudent*stu){structstudent*p0,*pl,*p2;pO=stu;if(head==NULL){head=pO;}//pO->next=head;else{pl二head;while((pO->num>p1->num)&&(p1->next!=head)){p2二pl;pl=pl->next

7、;}if(pO->num<=p1->num){if(head==p1){pO->next=pI;p1->prior->next=pO;p1->prior=pO;pO->prior=p1->prior;head=pO;)else{p2->next=p0;p0->next=p1;p0->prior=p2;p1->prior=pO;}}else{p1->next=pO;pO->prior=p1;pO->next=head;head->prior=pO;}}n=n+l;return(head);}structstudent*query(st

8、mc(student*head,structstudent*stud){structstudent*p1;pl=head;if(head==NULL){printf("空表");rctumhead;}whilc((pl->num!=stud->num)&&(pl->ncxt!=hcad))pl=pl->next;if(p1->num==stud->num)printf(Hnum%ld,score%5.1fstudenthasexistn,pl->num,p1->score);elseprintf(uthestudentnotex

9、istH);}structstudent*modify(structstudent*head,structstudent*mod){structstudent*p3;p3=head;printf("thisis%5.lfM,m

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

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

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