void Adjust(int* p, int sz)
{
int* front = p;
int* rear = p + 1;
while (*rear < sz)
{
if ((*front & 1) != 0 && (*rear & 1) == 0)
{
front++;
rear++;
}
else if ((*front & 1) == 0 && (*rear & 1) != 0)
{
int tmp = *front;
*front = *rear;
*rear = tmp;
}
else if ((*front & 1) == 0 && (*rear & 1) == 0)
{
rear++;
}
}
}
void print(int* p, int sz)
{
for (int i = 0; i < sz; i++)
{
printf("%d ", *p++);
}
printf("\n");
}
int main()
{
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int sz = sizeof(arr) / sizeof(arr[0]);
print(arr, sz);
Adjust(arr, sz);
print(arr, sz);
return 0;
}