C # algorithm ---- (3) Hill sort

zhaozj2021-02-08  237

Friends, I have recently stepped up some algorithms of writing C #. Select sort and insert algorithm is I have already launched. Now I launched Hill sort. In the future, if I have time I will launch other algorithms to write.

Hill Sort is sorted in insertion of groups.

For friends who want to improve C # language programming capabilities, we can explore each other.

Such as: The following procedure is not realized, come to help it implement. Using system;

Public Class Shellsorter

{

Public void sort (int [] list)

{

INT INC;

For (Inc = 1; Inc <= List.Length / 9; Inc = 3 * Inc 1);

For (; inc> 0; inc / = 3)

{

For (int i = inc 1; i <= list.length; i = inc)

{

INT T = List [i-1];

INT j = i;

While ((j> inc) && (list [j-inchem-1]> t))

{

List [J-1] = List [J-INC-1];

J- = INC;

}

List [J-1] = T;

}

}

}

}

Public class mainclass

{

Public static void main ()

{

INT [] IARRARY = new int [] {1,5, 3, 6, 10, 55, 9, 2, 87, 12, 34, 75, 33, 47};

ShellsORTER SH = New shellsorter ();

Sh.sort (IARRARY);

For (int m = 0; m <= 13; m )

Console.writeLine ("{0}", IARRARY [M]);

}

}

It has been compiled.

转载请注明原文地址:https://www.9cbs.com/read-2535.html

New Post(0)