//找到了返回x位置下标,没有找打返回-1
int SeqListFind(SL* ps,SLDataType x)
{
for (i =0;i<ps->size;i++)
{
if(ps->a[i]==x)
{
return i;
}
}
return -1;
}
//指定pos下标位置插入
void SeqListInsert(SL*ps,int pos,SLDataType x)
{
//第一种
if(pos>ps->size||pos<0)
{
printf("pos invalid\n");
return;
}
//第二种
//assert(pos<=ps->size && pos>=0)
SeqListCheckCapacity(ps);
int end=ps->size-1;
//挪动数据
while(end>=pos)
{
ps->a[end+1]=ps->a[end];
--end;
}
ps->a[pos]=x;
ps->size++;
}
//删除pos位置的数据
void SeqListErase(SL* ps,int pos)
{
assert(pos>=0 && pos<ps->size);
int begin=pos+1;
while(begin<ps->size)
{
ps->a[begin-1]=ps->a[begin];
++begin;
}
ps->size--;
}