




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include stdio.htypedef char DataType;typedef struct nodeDataType data;struct node *next;ListNode,*LinkList;LinkList CreatListF(void)char ch;LinkList head=(ListNode *)malloc(sizeof(ListNode);ListNode *s;ch=getchar();while(ch!=n)s=(ListNode *)malloc(sizeof(ListNode);s-data=ch;s-next=head-next;head-next=s;ch=getchar();return head;void Dowm(LinkList L)ListNode *p,*q,*s;p=L-next;q=p-next;p-next=NULL;while(q!=NULL)s=q-next; L-next=q;q-next=p;p=q;q=s;void InsertLink(LinkList L,DataType x)ListNode *p,*q,*s;int j;s=(ListNode *)malloc(sizeof(ListNode);s-data=x;p=L-next;while(p-datanext;if(p=NULL) j=1;break;if(j!=1)q-next=s;s-next=p;elseq-next=s;s-next=NULL;main()LinkList l;ListNode *p;l=CreatListF();Dowm(l);p=l-next;while(p!=NULL)printf(%c,p-data);p=p-next;return 0;#include stdio.htypedef int DataType;typedef struct nodeDataType data;struct node *next;ListNode,*LinkList;LinkList CreatListF(void)int ch;LinkList head=(ListNode *)malloc(sizeof(ListNode);ListNode *s;ch=getchar();while(ch!=n)s=(ListNode *)malloc(sizeof(ListNode);s-data=ch;s-next=head-next;head-next=s;ch=getchar();return head;void Dowm(LinkList L)ListNode *p,*q,*s;p=L-next;q=p-next;p-next=NULL;while(q!=NULL)s=q-next; L-next=q;q-next=p;p=q;q=s;void InsertLink(LinkList L,DataType x)ListNode *p,*q,*s;int j;s=(ListNode *)malloc(sizeof(ListNode);s-data=x;p=L-next;while(p-datanext;if(p=NULL) j=1;break;if(j!=1)q-next=s;s-next=p;elseq-next=s;s-next=NULL;main()LinkList l;ListNode *p;char x;l=CreatListF();printf(please the char:);scanf(%c,&x);InsertLink(l,x);p=l-next;while(p!=NULL)printf(%c,p-data);p=p-next;return 0;/*实现非空单链表的就地逆置*/#include /*单链表结点数据类型说明*/typedef char DataType;typedef struct node DataType data; struct node *next; ListNode,*LinkList;/*尾插法建立单链表*/LinkList CreatList()DataType ch;LinkList head;ListNode *s,*r;head=(ListNode *)malloc(sizeof(ListNode);r=head;while(ch=getchar()!=n)s=(ListNode *)malloc(sizeof(ListNode);s-data=ch;r-next=s;r=s;r-next=NULL;return head;/*链表元素输出运算PrintList(L)的实现*/void PrintList(LinkList L)ListNode *p; p=L-next; while(p!=NULL) printf( %c ,p-data); p=p-next; printf(n);/*对单链表进行就地逆置*/void invert(LinkList L)ListNode *p,*q,*s;p=L-next;q=p-next;p-next=NULL;while(q!=NULL)s=q-next;L-next=q;q-next=p;p=q;q=s;main()int i;LinkList La;clrscr();printf(please input some characters to creat List:);La=CreatList();PrintList(La);printf(the inverted result is:);invert(La);PrintList(La);getchar();#include #define M 10typedef structchar name10;char age10;int score;student;typedef struct student dataM;int length;s;void readdata(s *L)int i;L-length=0;for(i=0;,&L-datai.age,&L-datai.score);L-length+;main()s *stu;int scor,i;char nam10;printf(please input students message:n);readdata(stu);printf(The ages max is: ntnametscoren);for(i=0;ilength;i+)if(stu-datai.age=max)printf(t%st%dn,,stu-datai.score);#include stdio.h#define MaxLen 6typedef struct studentchar name20;int age;int score;datatype;typedef struct nodedatatype dataMaxLen;int length;Stu;Stu s;void input(Stu *x)int i;x-length=0;printf(Please input five student data:n);for(i=0;);printf(please input the Age :);scanf(%d,&x-datai.age);printf(please input the Score :);scanf(%d,&x-datai.score);x-length+;printf(complete!n);void out(Stu *x)int i;for(i=0;ilength;i+)printf(Name:);printf(%s,);printf(age:);printf(%d,x-datai.age);printf(score:);printf(%dn,x-datai.score);void oldfind(Stu *x)void average(Stu *x)void nameinput(Stu *x)main()int i,a;input(&s);oldfind(&s);average(&s);nameinput(&s);out(&s);#include stdio.h#include malloc.h#define NULL 0typedef int elemtype;typedef struct selemtype data;struct s *prior,*next;s;s* creat()int i,x;s *head,*p,*q;head=(s *)malloc(sizeof(s);head-prior=NULL;head-next=NULL;p=head;for(i=0;idata=x;q-next=p-next;q-prior=p;p-next=q;p=q;return head;void print(s *sq)int i;s* p;p=sq-next;while(p)printf(%dt,p-data);p=p-next;void insert(s *sq)int i;s *p,*x;p=sq-next;while(p)if(p-data=59)x=(s*)malloc(sizeof(s);x-data=JKN;p-next-prior=x;x-next=p-next;p-next=x;x-prior=p;p=x-next;else p=p-next;main()int i;s *sqx,*p,*x;printf(input 5 numbers:n);sqx=creat();printf(nthe sqlist is:n);print(sqx);insert(sqx);printf(nthe new sqlist is:n);print(sqx);/*利用已有基本运算,实现删除单链表中值为x的元素的函数void DL(LinkList L,DateType x)*/#include /*单链表结点数据类型说明*/typedef char DataType;typedef struct node DataType data; struct node *next; ListNode,*LinkList;/*查找运算locate(L,x)的实现(返回int值)*/int Locate(LinkList L,DataType x)ListNode *p=L-next;int i=1;while(p!=NULL & p-data!=x)p=p-next;i+;if(p=NULL) return 0; else return i;/*尾插法建立单链表*/LinkList CreatList()DataType ch;LinkList head;ListNode *s,*r;head=(ListNode *)malloc(sizeof(ListNode);r=head;while(ch=getchar()!=n)s=(ListNode *)malloc(sizeof(ListNode);s-data=ch;r-next=s;r=s;r-next=NULL;return head;/*链表元素输出运算PrintList(L)的实现*/void PrintList(LinkList L)ListNode *p; p=L-next; while(p!=NULL) printf( %c ,p-data); p=p-next; printf(n);/*求链表长度,在删除运算DeleteList(L,i)中需要用到*/int GetLength(LinkList L)int num=0; ListNode *p; p=L-next; while(p!=NULL) num+;p=p-next; return(num);/*链表的删除运算DeleteList(L,i)的实现,删除链表中的第i个元素*/void DeleteList(LinkList L,int i)int pos=1; ListNode *q=L,*p;if(iGetLength(L) exit(1); while(posnext; pos+; p=q-next; q-
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 施工现场机械设备管理
- 图形图像处理数码照片处理之缔造完美肌肤21课件
- 输电线路遥控调度方案
- 消防设施日常检查与维护方案
- 一矿物质概念及特点安徽医学高等专科学校79课件
- 水电基础知识培训资料课件
- 二零二五年度安防监控安装工程一切险保险协议
- 2025版图书馆数字资源与实体图书购销一体化协议
- 二零二五年度军队房地产租赁合同续签审批文件页2
- 二零二五年度离婚案件律师全面代理协议
- 河南省濮阳市2024-2025学年八年级上学期11月期中语文试题(含答案)
- 浪潮社会招聘在线测评题
- 电缆价格自动核算表
- 2024年内蒙古呼伦贝尔农垦拉布大林上库力三河苏沁农牧场招聘115人历年高频考题难、易错点模拟试题(共500题)附带答案详解
- 2024年全国网络安全行业职业技能大赛(数据安全管理员)考试题库-下(多选、判断题)
- 储藏室买卖协议模板
- 知识题库-人社练兵比武竞赛测试题及答案(九)
- 麦冬(浙麦冬)规范化生产技术规程
- 2024-2029年N-甲基吗啉N-氧化物(NMMO)行业市场现状供需分析及市场深度研究发展前景及规划投资研究报告
- 技术交底记录(通风)
- 2024年浙江温州乐清市公安局警务辅助人员招聘笔试参考题库附带答案详解
评论
0/150
提交评论