#include <iostream> #include<iomanip> #include <string> using namespace std; void partisons(int list[], int listSize); int main() { const int size1 = 6; int list1[size1]; for (int i = 0; i <size1 ; i++) { cin >> list1[i]; } selectionSort(list1, size1); for (int i = 0; i < size1; i++) { cout << list1[i] << " "; } } void partisons(int list[], int listSize) { int first = 0; int low = first + 1; int high = listSize - 1; int pivot = list[first]; while (high > low) { while (low <= high && list[low] <= pivot) { low++; } while (low <= high && list[high] > pivot) { high--; } if (high > low) { int temp = list[high]; list[high] = list[low]; list[low] = temp; } } while (high >= low && list[high] >= pivot) high--; if (high > first) { int temp = list[high]; list[high] = list[first]; list[first] = temp; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter