Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <utility>
- using namespace std;
- void pisz(int t[], int n) {
- for (int i=0; i < n; i++)
- cout << t[i] << ' ';
- cout << endl;
- }
- int main() {
- int n;
- cin >> n;
- int tab[n];
- for (int &x: tab) cin >> x;
- for (int k = n; k >= 2; k--) {
- int licz = 0;
- for (int j = 1; j < k; j++)
- if (tab[j-1] > tab[j]) swap(tab[j-1], tab[j]), licz++;
- if (licz == 0) break;
- pisz(tab, n);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement