标签:tor 交换 设置 inf img span pre ++ 奇数
题目:
解答:
r
是奇数,指针往右走l
交换一次l
1 class Solution { 2 public: 3 vector<int> sortArrayByParity(vector<int>& A) 4 { 5 int l = 0; 6 for (int r = 0; r < A.size(); r++) 7 { 8 if ((A[r] & 1) != 0) 9 { 10 continue; 11 } 12 swap(A[l++], A[r]); 13 } 14 return A; 15 } 16 };
标签:tor 交换 设置 inf img span pre ++ 奇数
原文地址:https://www.cnblogs.com/ocpc/p/12827652.html