Sorting P82924


Statement
 

pdf   zip

Sorting

Given a sequence of positive integer numbers, your program must print first the even numbers in increasing order, and then the odd numbers in decreasing order.

Input

The input consists of zero or more cases. Each case consists of a line with at most 10000 integer numbers strictly positive. Each line ends with a 0 that indicates the end.

Output

For each case, your program must print a line with the even numbers in non decreasing order, and in the following line the odd numbers in non increasing order.

Author

Salvador Roura (en: Carlos Molina)

© Jutge.org, 2006–2025.

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++ Haskell