C # Sort Algorithm Daquan

xiaoxiao2021-03-06  73

C # Sort Algorithm Dachels 2004-7-21 First, Bubble Using System; Namespace Bubblesorter {Public Class Bubblesorter {PUBLIC VOID SORT (int [] list) {Int i, j, temp; bool done = false ; J = 1; While ((j list [i 1]) {DONE = false; temp = list [i]; list [i] = list [i 1]; list [i 1] = Temp;}} j ;}}} public class mainclass}} Public static void main () {int [] arary = new int {1, 5, 13, 6, 10, 55, 99, 2, 87, 12, 34, 75, 33, 47}; bubblesorter sh = New Bubblesorter (); Sh.Sort (IARRARY); For (int m = 0; M 0) &&

(List [j-1]> t)) {list [j] = list [j-1]; --j;} list [j] = t;}}} public class mainclass}}} public class mainclass}}} public class mainclass}}} INT [] IARRARY = New int [] {1, 13, 3, 6, 10, 55, 98, 2, 87, 12, 34, 75, 33, 47}; INSERTIONORTER II = New InsertionsRionSorter (); II.Sort (IARRARY); For (int m = 0; m ) console.write ("{0}", IARRARY [M]); console.writeline ();}}} 4, Hill sort ( SHELLSORTER USING SYSTEM; NAMESPACE ShellsORTER {PUBLIC CLASS SORT (INT) {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-inc 3]> T)) {list [j-1] = list [j-inchem "; j- = inc;} list [j-1] = T }}}} Public class mainclass {public static void main () {int [] IARRARY = new int {] 1 1r = new int [] {1, 5, 13, 6, 10, 55, 99, 2, 87, 12, 34, 75, 33, 47}; shellsorter sh = new shellsorter (); sh.sort (IARRARY); For (int m = 0; M

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

New Post(0)