设为首页 加入收藏

TOP

用数组实现线性表各种操作(C语言)完结(二)
2014-11-23 22:37:13 来源: 作者: 【 】 浏览:5
Tags:实现 线性 各种 操作 语言 完结
)

{

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];

}

}

}

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言中PostMessage And SendMess.. 下一篇C语言易出的bug

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: