【发布时间】:2020-11-23 20:35:49
【问题描述】:
https://leetcode.com/problems/move-zeroes/ 正在解决这个问题。 但这不会编译。
void moveZeroes(vector<int>& nums) {
stable_sort(nums.begin(), nums.end(),[](int& a, int& b){
if(a == 0 && b != 0){
return false;
}
if(a != 0 && b == 0){
return true;
}
else {return false;}
});
}
但是,如果我们使用按值传递,即
(int a, int b) 它编译。
根本问题是什么??
【问题讨论】:
-
你的编译器给你什么错误信息?
标签: c++ sorting lambda stl stable-sort