mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:08:47 +00:00
32. 调整数组顺序使奇数位于偶数前面
https://www.acwing.com/problem/content/submission/code_detail/14064439/
This commit is contained in:
parent
e0b77729a1
commit
e8d751e963
12
AcWing/32/32.cpp
Normal file
12
AcWing/32/32.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
class Solution {
|
||||
private:
|
||||
static bool cmp(int a, int b) {
|
||||
return a % 2 == b % 2 ? a < b : a % 2 == 1;
|
||||
}
|
||||
|
||||
public:
|
||||
vector<int> reOrderArray(vector<int>& nums) {
|
||||
sort(nums.begin(), nums.end(), cmp);
|
||||
return nums;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user