#include #include #include using namespace std; int main(int argc, char * argv[]) { size_t size{100}; if (argc > 1) { size_t tmp = stoi(argv[1]); cout << "Tmp is " << tmp << endl; if (tmp >= 10) { size = tmp; } } srand(time(nullptr)); cout << "Running with " << size << " elements." << endl; vector A; for(int i = 0; i < size; ++i) { A.push_back(rand() % 1'000'000); } for(size_t current = 0; current < A.size(); ++current) { int small = current; for(size_t next = current+1; next < A.size(); ++next){ if (A[next] < A[small]) { small = next; } } if (current != small) { swap(A[current], A[small]); } } for(int i = 0; i < A.size() -1; ++i) { if (A[i] > A[i+1]) { cout << "Error in sort at position " << i << endl; } } return 0; }