Enter an array of integers to implement a function that adjusts the order of the numbers in the array so that all the odd digits in the array are in the first half of the array, and all the even digits are in the second half of the array//first method: #include <stdio.h>void Reverse (Int *p,int len) { int *start = p; int *end = p + len - 1; int tmp = 0; while (start < end) { if ((*start) % 2 == 1) { start++; } else { if ((*end % 2 == 0)) { end--; } else { tmp = *start; *start = *end; * End = tmp; } } }}int main () { int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int Len = sizeof (arr) &Nbsp;/ sizeof (Arr[0]); reverse (Arr,len); int i = 0; for (i = 0; i < 10; i++) { printf ("%d ", arr[i]); } return 0;} The second method: #include <stdio.h>void swap (INT&NBSP;*PA,&NBSP;INT*PB) { int tmp = *pa; *pa = *pb; *pb = tmp;} Int main () { int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int left = 0; int right = sizeof (arr) / sizeof (Arr[0]) -1; while (left < right) { while ((left < right) && (arr[left] % 2 == 1) { left++; } while (left < right) && (arr[right] % 2 == 0)) { right--; } if (left < right) { swap (&arr[ Left], &arr[right]); left++; right--; } } int i = 0; for (i = 0; i < sizeof (arr) / sizeof (Arr[0]); i++) { printf ("%d ", arr[i]); } printf (" \ n "); return 0;}
Make an array of odd digits in front of even numbers