123456789101112131415161718192021222324252627 |
- #include <iostream>
- int main() {
- int arr[] = {12, 11, 13, 5, 6};
- int n = sizeof(arr) / sizeof(arr[0]);
- for (int i = 1; i < n; i++) {
- int key = arr[i];
- int j = i - 1;
- while (j >= 0 && arr[j] > key) {
- arr[j + 1] = arr[j];
- j--;
- }
- arr[j + 1] = key;
- }
- std::cout << "Отсортированный массив: ";
- for (int i = 0; i < n; i++) {
- std::cout << arr[i] << " ";
- }
- std::cout << std::endl;
- return 0;
- }
|