#include <iostream>
#include <Windows.h>
using namespace std;
void swap(int *num1,int *num2){
int temp = *num1;
*num1 = *num2;
*num2 = temp;
}
int main() {
int ret[] = { 161,156,170,164,158,180,159,185,172,176 };
int len = sizeof(ret) / sizeof(ret[0]);
for (int i = 0; i < len - 1; i++) { //len个元素,执行len-1步选择
int max = 0;
for (int j = 1; j < len - i; j++) {//查找未排序的元素
if (ret[j]>ret[max]) {
max = j; //找到未排序元素的最大值
}
}
if (max != len - i - 1) { //把最大值和最后一个元素交换
swap(ret[max], ret[len - i - 1]);
}
}
for (int i = 0; i < len; i++) {
cout << ret[i] << " ";
}
cout << endl;
system("pause");
return 0;
}