-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsapxep.c
57 lines (54 loc) · 1.18 KB
/
sapxep.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int a[n + 3];
int chan[1000], le[1000];
int c = 0, l = 0;
for (int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
if (a[i] % 2 == 0)
chan[c ++] = a[i];
else {
le[l ++] = a[i];
}
}
for (int i = 0; i < c; i ++){
for (int j = i + 1; j < c; j ++){
if (chan[i] >= chan[j]){
int t = chan[i];
chan[i] = chan[j];
chan[j] = t;
}
}
}
for (int i = 0; i < c; i ++){
printf("%d ", chan[i]);
}
for (int i = 0; i < l; i ++){
for (int j = i + 1; j < l; j ++){
if (le[i] < le[j]){
int t = le[i];
le[i] = le[j];
le[j] = t;
}
}
}
for (int i = 0; i < l; i ++){
printf("%d ", le[i]);
}
printf("\n");
int n1 = 0, n2 = 0;
for (int i = 0; i < n; i ++){
if (a[i] % 2 == 0)
a[i] = chan[n1 ++];
else
a[i] = le[n2 ++];
}
for (int i = 0; i < n; i ++){
printf("%d ", a[i]);
}
}