#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#define MX 655
int main()
{
int n;
printf("Please eneter size array:");
scanf("%i",&n);
int ar[MX];
//Input numbers
printf("Please enter numbers:\n");
for (int i = 0; i < n; i++)
scanf("%i", &ar[i]);
for (int i = 0; i < n-1; i++)
{
for (int j = i+1; j < n; j++)
{
if (ar[i] % 2 == 0 && ar[j] % 2)
{
int tm = ar[i];
ar[i] = ar[j];
ar[j] = tm;
}
}
}
//Out numbers
for (int i = 0; i < n; i++)
printf("%i ", ar[i]);
//O n^2
return 0;
}
//Input
//Numbers [10]={5,7,9,98,3,65,54,2,13,15}
//There are several ways
//for example
//5 7 9 3 65 13 15 2 98 54
//5 7 9 3 13 65 15 98 54 2
//.............
Comments
Leave a comment