shell排序C实现

shell排序实际上是步长变化的插入排序,中间过程与插入排序没多大区别。

#include 
#include 
#define LEN 100
int arr[LEN];

void shellSort(int *arr,int len)
{
  int step;
  int i,j;
  for(step=len/2;step>=1;step=step/2)
  {
      for(i=step;i=0&&arr[j]>temp)
          {
              arr[j+step]=arr[j];
              j-=step;
          }
          j+=step;
          arr[j]=temp;
      }
  }
}

int main()
{
    int i;
    for(i=0;i


你可能感兴趣的:(数据结构(C),排序,数据结构,算法)