基于C语言实现的线性表
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define ERROR 0
#define OK 1
#define True 1
#define False 0
#define LIST_INIT_SIZE 5
#define LISTINCREAMENT 5
typedef int ElemType;
typedef int Status;
typedef struct Sqlist{
ElemType *elem;
int length;
int listsize;
}Sqlist;
Status InitList_sq(Sqlist &L);
Status CreateList_sq(Sqlist &L,int n);
Status ListInsert_sq(Sqlist &L,int i,ElemType e);
void PrintList_sq(Sqlist L);
Status ListDelete_sq(Sqlist &L,int i,ElemType &e);
int ListLocate_sq(Sqlist L,ElemType e);
void DestroyList_sq(Sqlist &L);
void ClearList_sq(Sqlist &L);
Status ListEmpty_sq(Sqlist L);
int ListLength_sq(Sqlist L);
Status GetElem_sq(Sqlist L,int i,ElemType &e);
Status InitList_sq(Sqlist &L)
{
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));