fork download
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<algorithm>
  4. #include<stdlib.h>
  5. #include<string.h>
  6. #define N 100000
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int ara[N];
  13. int tc;
  14.  
  15. while(scanf("%d",&tc)==1){
  16.  
  17. for(int i=0;i<tc;i++){
  18. scanf("%d",&ara[i]);
  19. }
  20.  
  21. sort(ara,ara+tc);
  22.  
  23. for(int j=0;j<tc;j++){
  24. if(ara[j]%2==0)
  25. printf("%d\n",ara[j]);
  26. }
  27.  
  28. for(int j=tc-1;j>=0;--j){
  29. if(ara[j]%2==1)
  30. printf("%d\n",ara[j]);
  31. }
  32.  
  33. } // end while
  34.  
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 15512KB
stdin
10
4
32
34
543
3456
654
567
87
6789
98
stdout
4
32
34
98
654
3456
6789
567
543
87