Skip to content

Instantly share code, notes, and snippets.

@l-arkadiy-l
Created June 3, 2021 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l-arkadiy-l/6662668989adcf579e21aeee14d04da3 to your computer and use it in GitHub Desktop.
Save l-arkadiy-l/6662668989adcf579e21aeee14d04da3 to your computer and use it in GitHub Desktop.
#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