86. Sort an Array in Descending Order

You are given an array of n unsigned 8-bit integers (uint8_t). Your task is to:

  • Sort the array in descending order using the bubble sort algorithm
  • Print the sorted array as space-separated values

Do not use any built-in sort functions. Use only loops and comparisons.

Example-1

Input: n = 5, arr = [10 3 5 2 7]
Output: 10 7 5 3 2


Example-2

Input: n = 3, arr = [0 128 255]
Output: 255 128 0


Example-3

Input: n = 1, arr = [42]
Output: 42


 

Loading...

Input

5 10 3 5 2 7

Expected Output

10 7 5 3 2