顺序表
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 50
#define OK 1
#define ERROR 0
typedef struct {
int data[MAXSIZE];
int length;
}SqList;
void InitList(SqList *&L){
L=(SqList*)malloc(sizeof(SqList));
L->length=0;
}
void CreatList(SqList *&L,int a[],int n){
int i;
L=(SqList*)malloc(sizeof(SqList));
for(i=0;i<n;i++){
L->data[i]=a[i];
}
L->length=n;
}
int IsEmpty(SqList *L){
return (L->length==0);
}
void Display(SqList *L){
int i;
if(IsEmpty(L))
printf("顺序表空!");
for(i=0;i<L->length;i++){
printf("%d ",L->data[i]);
}
printf("\n");
}
int InsertList(SqList *&L,int index,int e){
if(index<0||index>L->length)<