Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <stack>
- using namespace std;
- int a[5001];
- int main() {
- int n;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- int k = 1;
- while (k) {
- k = 0;
- for (int i = 0; i < n - 1; i++) {
- if (a[i] > a[i + 1]) {
- swap(a[i], a[i + 1]);
- k++;
- }
- }
- }
- for (int i = 0; i < n; i++) {
- cout << a[i] << ' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment