源代码 #include<iostream> #include <vector> using namespace std; void choose_sort(vector<int>& point) { int min_num; int flag = 0; for (int i = 0; i < point.size(); i++) { min_num = point[i]; flag = i; for (int j = i; j < point.size(); j++) { if (point[j] < min_num) { min_num = point[j]; flag = j; } } int temp; temp = point[flag]; point[flag]= point[i]; point[i] = temp; } } int main() { vector<int> point = { 9,7,5,3,4,6}; choose_sort(point); for (int i = 0; i < point.size(); i++) { cout << point[i] << endl; } system("pause"); return 0; }