#include<stdio.h>
void reverseArr(int* arr,int len)
{
int left=0;
int right=len-1;
while(left<right)
{
while(left<right && arr[left]%2==1)
{
left++;
}
while(left<right && arr[right]%2==0)
{
right--;
}
if(left<right)
{
int temp;
temp=arr[left];
arr[left]=arr[right];
arr[right]=temp;
}
}
}
void printfArr(int* arr,int len)
{
int i=0;
for(i=0;i<len;i++)
{
printf("%d ",*(arr+i));
}
}
int main()
{
int arr[]={1,2,3,4,5,6,7,8,9,10};
int len=sizeof(arr)/sizeof(arr[0]);
printfArr(arr,len);
reverseArr(arr,len);
putchar('\n');
printfArr(arr,len);
}
10-30
1883
10-29
403