Run ID:150030
提交时间:2026-03-21 16:34:50
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } // 插入排序 for (int i = 1; i < n; ++i) { int key = a[i]; int j = i - 1; while (j >= 0 && a[j] > key) { a[j + 1] = a[j]; j--; } a[j + 1] = key; } // 输出 for (int i = 0; i < n; ++i) { if (i > 0) cout << " "; cout << a[i]; } cout << endl; return 0; }