我写的希而排序

/*=======================================================
* 函 数 名: Shell_sort(int *, int )
* 参数说明:  pArray 为传入的数组
              iCount 为数组的个数
* 功能描述:  将 pArray 按照从小到大的顺序排序
* 返 回 值:  void
=======================================================*/

void Shell_sort(int *const pArray, int iCount)
{
 int iShell;             // 希尔系数
 int iOut_circle;        // 外层循环
 int iIn_circle;         // 内层循环
 int iTemp;              // 临时变量
 
 for (iShell = iCount/2; iShell > 0; iShell /= 2) /*控制增量*/
 {
  for (iOut_circle = iShell; iOut_circle < iCount; iOut_circle++) /*调用直接插入排序*/
  {
   iTemp = *(pArray + iOut_circle);
   for (iIn_circle = iOut_circle - iShell;
         ((iIn_circle >= 0) && (iTemp < *(pArray + iIn_circle)));
      iIn_circle -= iShell)
   {
    *(pArray + iIn_circle + iShell) = *(pArray + iIn_circle);
   }
   *(pArray + iIn_circle + iShell) = iTemp;
  }
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值