- 6
- 0
- 约5.48千字
- 约 7页
- 2016-12-25 发布于重庆
- 举报
#include malloc.h
#include stdio.h
#include stdlib.h
#include conio.h
#include iostream.h
#include string.h // 顺序表定义
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define IN_THIS_LIST 1
#define NOT_IN_THIS_LIST 0 //宏定义
typedef char Elemtype;
typedef int Status;
typedef struct List
{
Elemtype data;
struct List *next;
}LNode,*LinkList; //结构体定义
Status InitList(LinkList L)
{
L=(LinkList)malloc(sizeof(LNode));
if(!L) exit(OVERFLOW);
L-data=NULL;L-next=NULL;
return OK;
} //构造表头
Status PrintList(LinkList L)
{
LinkList PrintList=L-next;
if(!L-next) {cout该集合为空!endl;return ERROR;}
while(PrintList-next)
{
coutPrintList-data,;
PrintList=PrintList-next;
}
coutPrintList-data;
coutendl;
return OK;
} //输出表中元素
Status InsertList(LinkList L,Elemtype e)
{
if((int)e97||(int)e122) return ERROR;
LinkList compare=(LinkList)malloc(sizeof(LNode));
LinkList insertdata=(LinkList)malloc(sizeof(LNode));
compare=L;
while(compare-next)
{
if(e==compare-next-data) return TRUE;
else if(e(compare-next-data))
{
insertdata-next=compare-next;
insertdata-data=e;
compare-next=insertdata;
return OK;
}
compare=compare-next;
}
insertdata-data=e;
compare-next=insertdata;
insertdata-next=NULL;
return OK;
} //向表中增加元素
Status DeleteList_data(LinkList L,Elemtype e)
{
LinkList Deletedata=L-next;
while(Deletedata-next)
{
if(!(Deletedata-next-next)(Deletedata-next-data==e))
{Deletedata-next=NULL; return OK;}
if(Deletedata-next-data==e)
{
Deletedata-next=Deletedata-next-next;
return OK;
}
Deletedata=Deletedata-next;
}
Deletedata=L-next;
if(Deletedata-data==e)
{
L-next=Deletedata-next;
return OK;
}
return ERROR;
}
Status jiaoji(LinkList La,LinkList Lb,LinkList L)
{
LinkList Pa=La-next;
LinkList Pb=Lb-next;
while(Pa)
{
while(Pb)
{
if(Pb-dat
您可能关注的文档
最近下载
- 2026年详版个人信用报告征信报告最新Word可编辑模版样板doc文件.docx
- 2026年春接力版(新教材)小学音乐一年级下册(全册)教学设计(附目录P160).docx
- 行者讲课脉法下篇.doc VIP
- 铁塔电池通讯协议.docx VIP
- 复旦大学课程汉语言文学原典精读李杜精读.pdf VIP
- 电商数据分析(微课版)课件全套 第1--10章 电商数据分析概述---数据分析报告与看板制作.pptx
- 异常子宫出血的护理查房.pptx
- 2025年中医执业医师个人工作计划范文.docx VIP
- 2024《中班幼儿饮食行为现状调查—以S幼儿园为例》12000字.docx VIP
- 2025年美容美发十年行业数据洞察报告.docx
原创力文档

文档评论(0)