提交时间:2024-08-19 20:48:54

运行 ID: 167928

#include<bits/stdc++.h> using namespace std; int n,a[1005]; int main(){ cin >> n; for(int i = 1; i <= n;i++) cin >> a[i]; for(int i = 1; i <= n; i++){ int mini = i; for (int j = i + 1; j <= n; i++) if(a[j] < a[mini]) mini = j; swap(a[i],a[mini]); } for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl; return 0; }