C#快速排序源碼演示
阿新 • • 發佈:2019-01-20
源碼 quic int 應該 ret code while 快速 art 如下的資料是關於C#快速排序演示的代碼,應該對各位朋友有用處。
private static int Partition (int[] list, int i, int j) { int Key = list [i]; while (i < j) { while (list [j] >= Key && i < j) j--; if(i< j) list [i++] = list [j]; while (list [i] <= Key && i < j) i++; IF (i < j) list [j--] = list[i]; } list [i] = Key; return i; } public static void QuickSort (int[] list, int low, int high) { if(low < high - 1) { int Key = Partition (list, low, high); QuickSort (list, low, Key - 1); QuickSort (list, Key + 1, high); } }
C#快速排序源碼演示