In: Computer Science
Using the idea of the Bubble Sort algorithm, design an algorithm in pseudocode that gets 3 numbers a, b, c, from the user, and prints the 3 numbers in ascending order
import
java.io.*;
import
java.util.*;
class
GFG
{
static
void
sort3(
int
arr[],
int
temp[])
{
// Insert
arr[1]
if
(arr[
1
] <
arr[
0
])
{
temp[
0
]
= arr[
0
];
arr[
0
]
= arr[
1
];
arr[
1
]
= temp[
0
];
}
// Insert
arr[2]
if
(arr[
2
] <
arr[
1
])
{
temp[
0
]
= arr[
1
];
arr[
1
]
= arr[
2
];
arr[
2
]
= temp[
0
];
if
(arr[
1
] <
arr[
0
])
{
temp[
0
]
= arr[
0
];
arr[
0
]
= arr[
1
];
arr[
1
]
= temp[
0
];
}
}
}