#include<stdio.h>
typedef int DataType;
#define MaxSize 1024
typedef struct
{
DataType data[MaxSize];
int Last;
}SeqList;
//添加运算
int SeqInsert(SeqList *L,DataType x,int i)
{
int j;
if((*L).Last==MaxSize-1)
{
printf("OverFlow\n");
return NULL;
}
else{
for(j=(*L).Last;j>=i-1;j--)
(*L).data[j+1]=(*L).data[j];
(*L).data[i-1]=x;
(*L).Last++;
}
return 1;
}
//删除运算
int SeqDelete(SeqList *L,int i)
{
int j;
if(i<1||i>(*L).Last+1)
{
printf("Position Error\n");
return NULL;
}
else
{
for(j=i;j<=(*L).Last+1;j++)
(*L).data[j-1]=(*L).data[j];
(*L).Last--;
}
return 1;
}
//创建线性表
void SeqCreate(SeqList *L)
{
int n,i;
printf("请输入n个数据\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("data[%d]=\n",i);
scanf("%d",&(*L).data[i]);
}
(*L).Last=n-1;
printf("\n");
}