Created
June 3, 2021 05:54
-
-
Save l-arkadiy-l/6662668989adcf579e21aeee14d04da3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define int long long | |
#define forn(i, n) for(int (i) = 0; (i) < (n); (i)++) | |
using namespace std; | |
const int N = 6; | |
signed main() { | |
int arr[N] = {5, 2, 8, 1, 9, 3}; | |
for (int i = 0; i < N; ++i) { | |
for (int j = 0; j < N - i - 1; ++j) { | |
if (arr[j] > arr[j + 1]){ // сортируем массив по возрастанию | |
swap(arr[j], arr[j + 1]); // переставляем элемент arr[j] и arr[j + 1] | |
} | |
} | |
} | |
// выводим элементы массива | |
for(auto c: arr){ | |
cout << c << " "; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment