C ++ common sort algorithm

xiaoxiao2021-03-06  45

C common sort algorithm selection from Yuguanglou's blog

// Select Sort Method SelectionSort (int Arr [], int N) template void selectsort (t arr [], int n) {int smallindex; // Table minimum content of the subscript INT Pass, J; / / Used to scan the subscript T Temp; // The range of temporary variables used to exchange table elements is 0 ~ n-2 for (Pass = 0; Pass Void Desort (t arr [], int N ) {Int smallIndex, larndex; // Take the smallest and maximum element in the table INT leftpass = 0, Rightpass = N-1, I, J; // Used to scan the sub-table from the left and right scan sub-tables T Temp ; // Temporary variable for exchange elements while (LeftPass <= rightpass) {// start scanning subtabs from the left and right side SMALLINDEX = LEFTPASS; LARGEINDEX = Rightpass; // J and I traverses the entire sub table arr [leftpass] ~ Arr [Rightpass] for (i = leftpass 1; i leftpass; j--) IF (arr [j]> arr [largeIndex]) LARGEINDEX = J;

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

New Post(0)