0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:16:28 +00:00

32. 调整数组顺序使奇数位于偶数前面

https://www.acwing.com/problem/content/submission/code_detail/14064439/
This commit is contained in:
Baoshuo Ren 2022-05-09 19:35:52 +08:00
parent e0b77729a1
commit e8d751e963
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

12
AcWing/32/32.cpp Normal file
View 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;
}
};