题目描述
给定一个值num和一个数组,把小于等于num的数放在数组左边,大于num的数放在数组右边
解法1:单指针规定小于等于范围
解法2:双指针相对而行
测试结果及代码
#include <iostream>
#include <stdlib.h>
using namespace std;
const int num = 5;
void printArray(int a[], int N) {
for (int i = 0; i < N; ++i) {
cout << a[i] << " ";
}
cout << endl;
}
void Swap(int &x, int &y) {
int t = x;
x = y;