1 /**************************************** 2 > File Name:test.c 3 > author:xiaoxiaohui 4 > mail:[email protected] 5 > created time:2016 May 26 Thursday 19 15 minutes, 12 seconds 6 ********************/ 7 8 #include <stdio.h> 9 #include <assert.h> 10 11 void adjust (int *array, int size) 12 { 13 assert (array); 14 assert (size > 0); 15 16 int* left = arrar; 17 int* right = arrar[size - 1]; 18 19 while (Right > left) 20 { 21 if ( (*left) & 1) == 0) //left for even 22 { 23 if ( (*right) & 1) &NBSP;==&NBSP;1) Odd 24 { 25 on the right swap (*left, *right); 26 left++; 27 right--; 28 } 29 else 30 { 31 right--; 32 } 33 } 34 else //If the left is not an even number, Then left++ 35 { 36 left++; 37 } 38 } 39 }
This article is from "Narcissus" blog, please make sure to keep this source http://10704527.blog.51cto.com/10694527/1783645
The adjustment array of the sword means the odd number is preceded by even (question 14)