return vector<int>({vec.begin(), vec.begin() + n});
例子:
vector<int> ans = {1, 2, 3};
vector<int> copy(ans.begin(), ans.begin() + 2);
for (int num : copy)
cout << num << " ";
输出:
1 2
return vector<int>({vec.begin(), vec.begin() + n});
例子:
vector<int> ans = {1, 2, 3};
vector<int> copy(ans.begin(), ans.begin() + 2);
for (int num : copy)
cout << num << " ";
输出:
1 2