希尔排序算法
public void ShellSort(int[] array)
{
int i,j,increment,temp;
for(increment = array.Length/2; increment>0; increment/=2)
{
for(i = increment; i<array.Length; i++)
{
temp = array[i];
for(j=i; j>=increment; j-=increment)
{
if(temp<array[j-increment])
{
array[j] = array[j-increment];
}
else
break;
}
array[j] = temp;
}
}
}
{
int i,j,increment,temp;
for(increment = array.Length/2; increment>0; increment/=2)
{
for(i = increment; i<array.Length; i++)
{
temp = array[i];
for(j=i; j>=increment; j-=increment)
{
if(temp<array[j-increment])
{
array[j] = array[j-increment];
}
else
break;
}
array[j] = temp;
}
}
}