//==========================================数组输出最小的k个数======================
class Solution {
public:
vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
vector<int>a; //定义 vector a,存放前K个数
for (int i = 0; i < k; i++) //冒泡排序,不用全部循环完,只要外部的K个
{
for (int j = i + 1; j < input.size(); j++)
{
if (input[i] > input[j])
{
int temp = input[i];
input[i] = input[j];
input[j] = temp;
}
}
a.push_back(input[i]); //排序出来的直接 push_back 到 a 中
}
return a;
}
};