36 lines
593 B
C
36 lines
593 B
C
#include <stdio.h>
|
|
|
|
void swap(int *arr, int l, int r);
|
|
|
|
int main(void) {
|
|
int n;
|
|
scanf("%d", &n);
|
|
|
|
int arr[n];
|
|
for (int i = 0; i < n; i++) {
|
|
scanf("%d", &arr[i]);
|
|
}
|
|
|
|
/* swap(arr, 0, 1); */
|
|
// Bubble sort
|
|
for (int i = 0; i < n; i++) {
|
|
for (int j = 0; j < n - 1; j++) {
|
|
if (arr[j] % 2 == 1 && arr[j + 1] % 2 == 0) {
|
|
swap(arr, j, j + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < n - 1; i++) {
|
|
printf("%d ", arr[i]);
|
|
}
|
|
printf("%d\n", arr[n - 1]);
|
|
return 0;
|
|
}
|
|
|
|
void swap(int *arr, int l, int r) {
|
|
int tmp = arr[l];
|
|
arr[l] = arr[r];
|
|
arr[r] = tmp;
|
|
}
|