-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivi_Con.java
More file actions
35 lines (30 loc) · 754 Bytes
/
Divi_Con.java
File metadata and controls
35 lines (30 loc) · 754 Bytes
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
29
30
31
32
33
34
35
public class Divi_Con {
public static void sort(int[] list) {
sort(list, 0, list.length - 1);
}
private static void sort(int[] list, int low, int high) {
if (low < high) {
int indexOfMin = low;
int min = list[low];
for (int i = low + 1; i <= high; i++) {
if (list[i] < min) {
min = list[i];
indexOfMin = i;
}
}
list[indexOfMin] = list[low];
list[low] = min;
sort(list, low + 1, high);
}
}
public static void main(String[] args) {
int[] list = new int[args.length];
for (int j = 0; j < args.length; j++){
list[j]= Integer.parseInt(args[j]);
System.out.printf(list[j] + " ","/n");
}
System.out.println();
sort(list);
System.out.print("The smallest integer is: " + list[0] );
}
}