Embercode
✕
SortingCoding problems

Sorting: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • Your teacher has a list of exam marks, one per student, in the order the papers were handed in. She wants the marks from highest to lowest so she can read off the top scores first. Sorting is the tool for this.

    Read the marks and print them in descending order (largest first), separated by single spaces, on one line.

    **Constraints:** 1 <= n <= 1,000. Each mark is an integer between -1,000,000,000 and 1,000,000,000. Marks can repeat and can be negative.

    Input. The first line holds n. The second line holds n integers.

    Output. One line with the n marks, largest first, separated by single spaces.

    Example 1 input

    5
    3 9 2 9 7
    

    Output

    9 9 7 3 2
    

    Example 2 input

    1
    42
    

    Output

    42