提交时间:2023-09-12 13:58:48

运行 ID: 102224

#include <iostream> using namespace std; int a[10005]; int main(){ int n; cin >> n; for (int i=1; i<=n; i++) cin >> a[i]; bool x = true; while (x){ x = false; for (int i=1; i<=n-1; i++){ if (a[i] > a[i + 1]){ x = true; swap(a[i], a[i + 1]); } } } for (int i=1; i<=n; i++){ cout << a[i] << " "; } }