1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 vector<int> sort(int n,vector<int> inputs,int p) { 6 int min = inputs[p], pos = p; 7 bool flag = false; 8 for (int i = p; i < n; i++) { 9 if (min > inputs[i]) { 10 flag &= false; 11 min = inputs[i]; 12 pos = i; 13 } 14 else { 15 flag &= true; 16 } 17 } 18 if (flag ==true||p==n-1) { 19 return inputs; 20 } 21 else { 22 int temp = 0; 23 temp = inputs[p]; 24 inputs[p] = min; 25 inputs[pos] = temp; 26 p = p + 1; 27 inputs = sort(n, inputs, p); 28 } 29 return inputs; 30 }
标签:inputs,temp,递归,min,int,pos,C++,flag,方法 From: https://www.cnblogs.com/yolo-m/p/16714637.html