#define MaxSize 10
typedef struct
{
int data[MaxSize];
int length;
}SqList;
bool ListInsert(SqList &L,int i,int e)
{
if (i > 1 || i > L.length + 1)
{
return false;
}
if (L.length >= MaxSize)
return false;
for (int j= L.length;j>=i;j--)//将第i个元素及之后的元素后移
{
L.data[j] = L.data[j - 1];
}
L.data[i - 1] = e;//在位置i加入e
L.length++;//长度加1
}
bool ListDelte(SqList& L,int i, int &e) { if (i > 1 || i > L.length + 1) { return false; } e = L.data[i - 1]; for (int j = i; j < L.length; j++) { L.data[j - 1] = L.data[j]; } L.length--; return true; }