Created
November 9, 2016 17:51
-
-
Save wuerges/8eb88b356704385d86b418c13c4aaf5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int n; | |
scanf("%d", &n); | |
int xs[n]; | |
int p_tam = 0; | |
int ps[n]; | |
int y_tam = 0; | |
int ys[n]; | |
for(int i = 0; i < n; ++i) { | |
int x; | |
scanf("%d", &x); | |
xs[i] = x; | |
} | |
for(int i = 0; i < n; ++i) { | |
//printf("%d\n", xs[i]); | |
if( xs[i] % 2 == 0) { | |
ps[p_tam] = xs[i]; | |
p_tam++; | |
} | |
else { | |
ys[y_tam] = xs[i]; | |
y_tam++; | |
} | |
} | |
sort(ps, ps+p_tam); | |
for(int i = 0; i < p_tam; ++i) { | |
printf("%d\n", ps[i]); | |
} | |
sort(ys, ys+y_tam); | |
reverse(ys, ys+y_tam); | |
for(int i = 0; i < y_tam; ++i) { | |
printf("%d\n", ys[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment