#K58022. Custom Bubble Sort Implementation

    ID: 30550 Type: Default 1000ms 256MiB

Custom Bubble Sort Implementation

Custom Bubble Sort Implementation

You are given an array of integers. Your task is to sort the array in ascending order by implementing the Bubble Sort algorithm without using any built-in sorting functions.

The Bubble Sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. Its time complexity is $$O(n^2)$$ in the worst-case scenario.

Important: Read input from stdin and write the sorted array to stdout. The sorted numbers should be output on a single line separated by a single space.

inputFormat

The input is given from stdin and consists of two lines:

  • The first line contains a single integer n representing the number of elements in the array.
  • The second line contains n space-separated integers.

outputFormat

Output the sorted array on one line. The numbers must be space-separated. Write the output to stdout.

## sample
6
34 7 23 32 5 62
5 7 23 32 34 62