diff options
| author | Andrew Guschin <guschin.drew@gmail.com> | 2022-05-19 14:12:12 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin.drew@gmail.com> | 2022-05-19 14:12:12 +0400 |
| commit | bc6fa2f8d7967acd859c0f660cad81199e53b0fb (patch) | |
| tree | 1cc2c59f70ed45073500e705cdd1dd8925450132 /straight-selection.cpp | |
| parent | da81a8f76f56a6b21dda16c8df5f1df5f9b962a3 (diff) | |
Добавление отчётов по первым трём лабам
Diffstat (limited to 'straight-selection.cpp')
| -rw-r--r-- | straight-selection.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/straight-selection.cpp b/straight-selection.cpp index ff5a7b6..86c8f94 100644 --- a/straight-selection.cpp +++ b/straight-selection.cpp @@ -7,18 +7,14 @@ straight_selection(std::vector<T> &array) { for (int i = 0; i < array.size(); ++i) { - int k = i; - int x = array[i]; for (int j = i; j < array.size(); ++j) { - if (array[j] < x) + if (array[j] < array[i]) { - k = j; - x = array[j]; + std::swap(array[i], array[j]); + break; } } - array[k] = array[i]; - array[i] = x; } } |