)
{
sqList[pos]=sqList[pos-1];
pos--;
}
sqList[pos]=temp;
}
//直接插入排序实现
void straisort(struct Arr * pArr)
{
for(int i=1;icnt;i++)
{
one_sort(pArr->pBase,pArr->pBase[i],i);//调用单步排序
}
}
//数组倒置
void inversion_arr(struct Arr * pArr )
{
int i = 0;
int j = pArr->cnt-1;//首尾下标的呼应关系
int t;
while (i < j)
{
t = pArr->pBase[i];
pArr->pBase[i] = pArr->pBase[j];
pArr->pBase[j] = t;
i++;
j--;
}
return;
}
//删除元素
bool delete_arr(struct Arr * pArr, int pos, int * pVal)
{
int i;
if ( is_empty(pArr) )
return false;
if (pos<1 || pos>pArr->cnt)
return false;
*pVal = pArr->pBase[pos-1];
for (i=pos; icnt; i++)
{
pArr->pBase[i-1] = pArr->pBase[i];
}
pArr->cnt--;
return true;
}
//判断是否已满
bool is_full(struct Arr * pArr)
{
if (pArr->cnt == pArr->len)
return true;
else
return false;
}
//查找元素
int get(struct Arr *pArr,int index)
{
for(int i=0;icnt;i++)
{
if(index==i)
{
return pArr->pBase[i];
}
}
}