全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
在这里列举了一个应用单链表基本算法的综合程序,双向链表和循环链表的综合程序大家可以自己去试一试。#include #include #include #define N 10 typedef struct nodechar name20;struct node *link;stud;stud * creat(int n)stud *p,*h,*s;int i;if(h=(stud *)malloc(sizeof(stud)=NULL)printf(不能分配内存空间!);exit(0);h-name0=0;h-link=NULL;p=h;for(i=0;ilink=s;printf(请输入第%d个人的姓名,i+1);scanf(%s,s-name);s-link=NULL;p=s;return(h);stud * search(stud *h,char *x)stud *p;char *y;p=h-link;while(p!=NULL)y=p-name;if(strcmp(y,x)=0)return(p);else p=p-link;if(p=NULL)printf(没有查找到该数据!);stud * search2(stud *h,char *x)stud *p,*s;char *y;p=h-link;s=h;while(p!=NULL)y=p-name;if(strcmp(y,x)=0)return(s);elsep=p-link;s=s-link;if(p=NULL)printf(没有查找到该数据!);void insert(stud *p)char stuname20;stud *s;if(s= (stud *) malloc(sizeof(stud)=NULL)printf(不能分配内存空间!);exit(0);printf(n请输入你要插入的人的姓名:);scanf(%s,stuname);strcpy(s-name,stuname);s-link=p-link;p-link=s;void del(stud *x,stud *y)stud *s;s=y;x-link=y-link;free(s);void print(stud *h)stud *p;p=h-link;printf(数据信息为:n);while(p!=NULL)printf(%s ,&*(p-name);p=p-link;void quit()exit(0);void menu(void)clrscr();printf(ttt单链表C语言实现实例n);printf(tt|n);printf(tt| |n);printf(tt| 1 建 立 新 表 |n);printf(tt| 2 查 找 数 据 |n);printf(tt| 3 插 入 数 据 |n);printf(tt| 4 删 除 数 据 |n);printf(tt| 5 打 印 数 据 |n);printf(tt| 6 退 出 |n);printf(tt| |n);printf(tt| 如未建立新表,请先建立! |n);printf(tt| |n);printf(tt|n);printf(tt 请输入你的选项(1-6):);main()int choose;stud *head,*searchpoint,*forepoint;char fullname20;while(1)menu();scanf(%d,&choose);switch(choose)case 1:head=creat(N);break;case 2:printf(输入你所要查找的人的姓名:);scanf(%s,fullname);searchpoint=search(head,fullname);printf(你所查找的人的姓名为:%s,*&searchpoint-name);printf(n按回车键回到主菜单。);getchar();getchar();break;case 3: printf(输入你要在哪个人后面插入:);scanf(%s,fullname);searchpoint=search(head,fullname);printf(你所查找的人的姓名为:%s,*&searchpoint-name);insert(searchpoint);print(head);printf(n按回车键回到主菜单。);getchar();getchar();break;case 4:print(head);printf(n输入你所要删除的人的姓名:);scanf(%s,fullname);searchpoint=search(head,fullname);forepoint=search2(head,fullname);del(forepoint,searchpoint);break;case 5:print(head);printf(n按回车键回到主菜单。);getchar();getchar();break;case 6:quit();break;default:printf(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 生物医疗传感器技术进展
- 口腔医学新技术在临床中的应用
- 电子病历系统在提高医疗质量中的作用
- 转基因技术在生物医药发展
- 法律知识更新及企业合规经营指南
- 法律事务处理流程与案例分析
- 2025 初中语文八年级上册 人无信不立 的教学故事与名言积累课件
- 跨界融合下的医疗行业创新
- 电气安装面试实战案例分析
- 电气行业发展趋势与面试要点分析
- 部队炊事骨干申请书
- 2025年智能网联汽车测试初级认证题集
- 《环境化学》戴树桂(第二版)课后习题答案
- 人教版小学数学四年级下册第四单元综合练习试题含答案共4套
- 南华大学《高等数学》2024-2025学年期末试卷(A卷)含答案
- 学堂在线 海权与制海权 结业考试答案
- 持续工艺确认培训课件
- 感染性心内膜炎超声病例分享
- DB14-T34292025全域土地综合整治项目可行性研究报告编制规范
- 助贷公司策划方案
- 洗车店维修管理制度
评论
0/150
提交评论