剑指offer---最小的k个数
class Solution { public: vector<int> GetLeastNumbers_Solution(vector<int> input, int k) { int in_size = input.size(); for (int i = 0; i < in_size; ++i) { for (int j = i; j < in_size; ++j) { if (input[i]>input[j]) { swap(input[i], input[j]); } } } vector<int> result = {}; if (k <= in_size) { for (int i = 0; i < k; ++i) { result.push_back(input[i]); } return result; } else { /*int lingdegeshu = (k - in_size); for (int i = 0; i < lingdegeshu; ++i) { result.push_back(0); } for (int j = 0; j < (in_size); ++j) { result.push_back(input[j]); }*/ return result; } } };