选择法排序
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
int arr[10] = { 0 };
for (int i = 0; i < 10; i++) {
cin >> arr[i];
}
for (int j = 0; j < 10;j++) {
for (int i = 0; i < 9; i++) {
int a = arr[i];
if (a > arr[i+1]) {
int temp;
temp= a;
a = arr[i+1];
arr[i+1] = temp;
arr[i] = a;
}
}
}
for (int i = 0; i < 10; i++) {
cout << arr[i] << endl;
}
}