选择排序
// 不稳定排序
#include <iostream> using namespace std; int main() { int arr[100], tmp; for (int i = 0; i < 10; i++) cin >> arr[i]; for (int j = 0; j <= 9; j++) { for (int k = j + 1; k < 10; k++) { if (arr[j] > arr[k]) { tmp = arr[j]; arr[j] = arr[k]; arr[k] = tmp; } } } for (int i = 0; i < 10; i++) cout << arr[i] << ' '; return 0; }