#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void display(int *arr, int n)
{
for (int i = 0; i < n; i++)
{
printf("%d ", arr[i]);
}
}
int main()
{
int n, x, y, a = 0, b = 0;
printf("enter the array size\n");
scanf("%d", &n);
int *arr = (int *)malloc(n * sizeof(int));
printf("enter the elements\n");
for (int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
for (int i = 0; i < n; i++)
{
if (arr[i] % 2 == 0)
{
a++;
}
}
for (int i = 0; i < n; i++)
{
if (arr[i] % 2 != 0)
{
b++;
}
}
int j = 0, even[a];
for (int i = 0; i < n; i++)
{
if (arr[i] % 2 == 0)
{
even[j] = arr[i];
j++;
}
}
int k = 0, odd[b];
for (int i = 0; i < n; i++)
{
if (arr[i] % 2 != 0)
{
odd[k] = arr[i];
k++;
}
}
for (int i = 0; i < a; i++)
{
arr[i] = even[i];
}
int l=0;
for (int i = a; i < n; i++)
{
arr[i] = odd[l];
l++;
}
display(arr,n);
return 0;
}