You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
403 B

1 year ago
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], n;
/*
5
2 3 1 4 5
*/
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i < n; i++) // n-1个阶段
for (int j = 1; j < n - i; j++)
if (a[j] > a[j + 1]) swap(a[j], a[j + 1]);
for (int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;
}