Separated investment with stacks P13304


Statement
 

pdf   zip

thehtml

Use stacks to reverse sequences of integer numbers. Print first the even numbers in reverse order, and afterwards the odd numbers in reverse order.

Input

Input consists of several sequences of integer numbers, one per line.

Output

For every line, print the even numbers in reverse order, followed by the odd numbers in reverse order, all them separated by spaces.

Observation

To solve this exercise, the only containers that you should use are stacks.

Public test cases
  • Input

    0 1 2 3 4 5 6 7
    10 10 20 10
    
    3 15 7 11
    -1 -2 -3 -4
    

    Output

    6 4 2 0 7 5 3 1
    10 20 10 10
    
    11 7 15 3
    -4 -2 -3 -1
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python