线性表的操作求高手来看一下
#include<stdio.h>#define LIST_INIT_SIZE 100
#define listincrement 10
//定义线性表的结构体表头
typedef struct
{
Elemtype *elem;
int length;
int listsize;
}Sq;
Initlist(Sq &L)
{
L.elem=(Elemtype * )malloc(LIST_INIT_SIZE * sizeof(Elemtype));
if(!L.elem)
return error;
int length=0;
int listsize=LIST_INIT_SIZE;
return ;
}
ListDelete(Sq &L,int i)
{
int j;
for(j=i+1;j<=L.length-1;j++)
L.elem[j-1]=L.elem[j];
L.length--;
}
ListInsert(Sq &L,int i,Elemtype x)
{
int j;
for(j=L.length;j>=i+1;j--)
L.elem[j+1]=L.elem[j];
L.elem[i+1]=x;
L.length++;
return ;
}
int main()
{
int L[9];
int i;
printf("please input 9 numbers");
for(i=0;i<9;i++)
scanf("%d",&L[i]);
ListDelete(L,5);
ListInsert(L,4,8);
}