顺序表的初始化插入删除等基本操作算法(C语言).doc
文本预览下载声明
/* Linear Table On Sequence Structure */
#include stdio.h
#includestdlib.h
#include string.h
#include windows.h
/*------------------------------------------------------*/
typedef int status;
#define LISTINCREMENT 10
#define LIST_INIT_SIZE 100
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
#define ERROR 0
#define OK 1
typedef struct{
int item1;
}Elemtype;
typedef struct{
Elemtype * elem;
int length;
int listsize;
}SqList;
/*------------------------------------------------------*/
status Getlist_One(SqList *L);
status SaveData(SqList * L);
status InitList_One(SqList *L);
status IntiaList(SqList * L);
status DestroyList(SqList * L);
status ClearList(SqList* L);
status ListEmpty(SqList L);
int ListLength(SqList L);
status GetElem(SqList L,int i,Elemtype * e);
status LocatElem(SqList L,Elemtype e);
/*
status PriorElem(SqList L,Elemtype cur,Elemtype * pre_e);
status NextElem(SqList L,Elemtype cur,Elemtype * next_e);
*/
status ListInsert(SqList * L,status i, Elemtype e);
status ListDelete(SqList * L);
status ListTrabverse(SqList L,void (* visit)(Elemtype e));
/*------------------------------------------------------*/
status equal(Elemtype x, Elemtype y);
void display(Elemtype e);
/*------------------------------------------------------*/
void menu(void);
/*------------------------------------------------------*/
void main(void){
SqList L1,L2;
int op=0;
L1.elem=L2.elem=NULL;
char*L1_info_filename=L1.dat;
InitList_One(L1);
/*
L1.elem=(Elemtype *) malloc(sizeof(Elemtype)*10);
L1.length=4;
L1.elem[0].item1=1;
L1.elem[1].item1=2;
L1.elem[2].item1=3;
L1.elem[3].item1=4;
*/
do{
//clrscr();
menu();
printf( Please input your option[0-12]:);
scanf(%d,op);
switch(op){
case 0: break;
case 1: printf(\n here is IntiaList(),which being realized\n);
if(IntiaList(L1)==OK)
printf(\n 初始化成功\n);
else
printf( 初始化失败\n);
getchar();g
显示全部