Advertisement
H0_0H

Untitled

Mar 18th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. typedef pair<int, int> PII;
  5. typedef pair<LL, LL> PLL;
  6.  
  7.  
  8.  
  9. void bubble_sort(vector<int> &v){
  10.     for (int i = 0; i < v.size() - 1; i++){
  11.         for (int j = 0; j < v.size() - i - 1; j++){
  12.             if (v[j] > v[j + 1]) swap(v[j], v[j + 1]);
  13.         }
  14.     }
  15. }
  16.  
  17. int main(){
  18.     int n, a;
  19.     cin >> n;
  20.     vector<int> v(n);
  21.     for (int i = 0; i < n; i++){
  22.         cin >> a;
  23.         v[i] = a;
  24.     }
  25.     bubble_sort(v);
  26.     for (auto c: v) cout << c << ' ';
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement