给定一个整数数组,通过变换使得数组的左边为奇右边为偶数!
[cpp]view plaincopyprint?/*给定一个存放整数的数组,重新排列数组使得数组左边为奇数,右边为偶数。 要求:空间复杂度O(1),时间复杂度为O(n)。//*/#include #include #include usingnamespace std; void swap_int(int& a, int& b) { int t = a; a = b; b = t; }
转载
2013-10-22 18:18:16 ·
1308 阅读 ·
0 评论