fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 1000;
  5.  
  6. int main() {
  7. int n, v[MAX_LENGTH + 1];
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> v[i];
  11. }
  12. for (int i = 1; i <= n; ++i) {
  13. if (v[i] % 2 == 0) {
  14. cout << v[i] << ' ';
  15. }
  16. }
  17. for (int i = n; i >= 1; --i) {
  18. if (v[i] % 2 != 0) {
  19. cout << v[i] << ' ';
  20. }
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty