• Source
    1. /// Author : Shohanur Rahaman
    2. /// URI : 1259
    3.  
    4. #include<stdio.h>
    5. #include<iostream>
    6. #include<algorithm>
    7. #include<stdlib.h>
    8. #include<string.h>
    9. #define N 100000
    10.  
    11. using namespace std;
    12.  
    13. int main()
    14. {
    15. int ara[N];
    16. int tc;
    17.  
    18. while(scanf("%d",&tc)==1){
    19.  
    20. for(int i=0;i<tc;i++){
    21. scanf("%d",&ara[i]);
    22. }
    23.  
    24. sort(ara,ara+tc);
    25.  
    26. for(int j=0;j<tc;j++){
    27. if(ara[j]%2==0)
    28. printf("%d\n",ara[j]);
    29. }
    30.  
    31. for(int j=tc-1;j>=0;--j){
    32. if(ara[j]%2==1)
    33. printf("%d\n",ara[j]);
    34. }
    35.  
    36. } // end while
    37.  
    38.  
    39. return 0;
    40. }
    41.  
    42.  
    43.  
    44.  
    45.  
    46.  
    47.  
    48.  
    49.  
    50.  
    51.  
    52.  
    53.