Separated sort P25992


Statement
 

pdf   zip

thehtml

Given a sequence of natural numbers, first, print the even numbers in increasing order, and then the odd numbers in decreasing order.

Input

Input consists of zero or more cases. Each case consists of a line with at most 1000 natural numbers strictly positive. Each line ends with a 0 that indicates the end.

Output

For each case, print in a line the even numbers in increasing order, and in the following line the odd numbers in decreasing order.

Public test cases
  • Input

    15 20 0
    1 2 3 4 5 6 7 8 0
    5 5 5 3 3 3 7 7 7 0
    

    Output

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