JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class Program {
public static void printArray(int arr[]) {
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
//This is how ascending numbers work
public static void main(String[] args) {
//3,9,8,7,8,1,2,4,3,
int arr[] = {3, 9, 8, 7, 8, 1, 2, 4, 3};
for (int i = 0; i < arr.length - 1; i++) {
int smallest = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[smallest] > arr[j]) {
smallest = j;
}
}
int temp = arr[smallest];
arr[smallest] = arr[i];
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run