Previous Next
0 / 15
Module DEMO-33-67DEMO-OOP-33

Bubble Sort Ascending

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Read five integers, sort them in ascending order using bubble sort, and print the sorted sequence.

Input Format

Input is given as whitespace-separated tokens in this order:

  1. value 1
  2. value 2
  3. value 3
  4. value 4
  5. value 5

Output Format

Print the exact report in this order:

  1. Sorted

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
5
2
4
1
3
Sorted: 1 2 3 4 5
Input: value 1 = 5, value 2 = 2, value 3 = 4, value 4 = 1, value 5 = 3.
Key calculation(s): values = {5, 2, 4, 1, 3} | for (int pass = 0; pass < values.length - 1; pass++) { | "Sorted: " + sorted.toString() = "Sorted: 1 2 3 4 5".
Output:
Sorted: 1 2 3 4 5
Sample #2
Public sample
9
8
7
6
5
Sorted: 5 6 7 8 9
Input: value 1 = 9, value 2 = 8, value 3 = 7, value 4 = 6, value 5 = 5.
Key calculation(s): values = {9, 8, 7, 6, 5} | for (int pass = 0; pass < values.length - 1; pass++) { | "Sorted: " + sorted.toString() = "Sorted: 5 6 7 8 9".
Output:
Sorted: 5 6 7 8 9

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings