fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Write your code here
  6. int n, i = 0, j = 0;
  7. int pare[1001], impare[1001];
  8. cin >> n;
  9. while (n--) {
  10. int t;
  11. cin >> t;
  12. if (t % 2 == 0){
  13. pare[i] = t;
  14. i++;
  15. }
  16. if (t % 2 == 1){
  17. impare[j] = t;
  18. j++;
  19. }
  20. }
  21. for (int i_ = 0; i_ < i; i_ += 1){
  22. cout << pare[i_] << " ";
  23. }
  24. for (int j_ = n - 1; j_ >= 0; j_ -= 1){
  25. cout << impare[j_] << " ";
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5320KB
stdin
5
1 8 7 4 5
stdout
8 4