(二)选择排序
以下程序实现输入 n 个整数,使用选择排序算法将其从小到大排序后输出。
#include <iostream>
using namespace std;
const int MAXN = 1005;
int a[MAXN];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < ⑤; i++) {
int min_index = i;
for (int j = i + 1; j < n; j++) {
if (⑥) {
⑦;
}
}
⑧;
}
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}
⑤处应填( )
n
n-1
n+1
n-2