C # implementation basic algorithm changqi [original]

xiaoxiao2021-03-06  94

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 [] IARRARY = 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

}

Select Sort I use C # to develop a sequencing algorithm. I hope to bring some benefits to learners in C # language. Don't forget, learn the language to spend vigorous gas data structure and algorithm.

Using system;

Namespace SelectionSORTER {public class selectionsorter {private int min; public void sort (int [] list) {for (int i = 0; i

}}}

Insert order

Insert the sort algorithm. 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;

Namespace INSERTIONSORTER {public void sort (int [] list) {for (int i = 1; i 0) && (list [j-1]> t)) {list [j] = list [j-1]; --j;} list [j] = t;}}} public class mainclass}}} public class mainclass}}} public class mainclass}}} Main () {int [] ararary = new int [] {1, 13, 3, 6, 10, 55, 98, 2, 87, 12, 34, 75, 33, 47}; INSERTIONSORTER II = New INSERTIONSORTER () Ii.Sort (IARRARY); For (int m = 0; M

Hill sort

Hill sort is sorted to insert the group, inserted. For friends who want to improve C # language programming capabilities, we can discuss each other. Such as: The following procedure is not realized, come to help it implement.

Using system;

Namespace shellsorter {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-INC-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, 13, 6, 10, 55, 99, 2, 87, 12, 34, 75, 33, 47}; ShellsRer sh = new shellsorter (); sh.sort (IARRARY); For (int m = 0; M

This basic algorithm implemented with C # is very good, that is, there is no indentation, I have a long time for a long time, depressed ing

Now I have to temporarily. It should be clear.

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

New Post(0)