剑指offer面试题14:调整数组顺序使奇数位于偶数前面
来源:互联网 发布:jre 8u91 windows x32 编辑:程序博客网 时间:2024/04/28 15:28
#include "iostream"using namespace std;void reOrder(int *data,int length){if (data == NULL || length <= 0)return;int* start = data;int *end = data + length - 1;while (start<end){while (start<end&&(*start & 1) != 0)start++;while (start<end&&(*end & 1) == 0)end--;if (start < end){int temp = *start;*start = *end;*end = temp;}}}int main(){int ia[] = {1,2,3,4,5};reOrder(ia, 5);for (int i = 0; i < 5;i++){cout << ia[i] << endl;}system("pause");return 0;}
0 0
- [剑指offer][面试题14]调整数组顺序使奇数位于偶数前面
- 剑指offer 面试题14 调整数组顺序使奇数位于偶数前面
- 《剑指Offer》面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer 面试题14—调整数组顺序使奇数位于偶数前面
- 《剑指Offer》学习笔记--面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer--面试题14:调整数组顺序使奇数位于偶数前面--Java实现
- 【剑指Offer学习】【面试题14 :调整数组顺序使奇数位于偶数前面】
- 剑指offer面试题14-调整数组顺序使奇数位于偶数前面
- 剑指offer-面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer之面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer之面试题14调整数组顺序使奇数位于偶数前面
- 剑指Offer----面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer--面试题14:调整数组顺序使奇数位于偶数前面
- 剑指offer面试题14: 调整数组顺序使奇数位于偶数前面
- 剑指offer——面试题14:调整数组顺序使奇数位于偶数前面
- 友盟分享完之后弹出dialog
- Object.defineProperty 函数 (JavaScript)
- HDU 3046 最大流最小割问题
- Java编程中操作XML文件(生成方法三:JDOM)
- android下JNI开发
- 剑指offer面试题14:调整数组顺序使奇数位于偶数前面
- 第二个Activity 以dialog对话框的方式出现
- Git4--管理修改
- JavaScript对象的property属性详解
- 各种动画
- 了解WiFi入门
- android一键退出
- 在Eclipse上打包并使用Proguard工具混淆jar包
- Git5--撤销修改