forked from bliblidotcom/training-java-future-program
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBubbleSort.java
More file actions
35 lines (28 loc) · 688 Bytes
/
Copy pathBubbleSort.java
File metadata and controls
35 lines (28 loc) · 688 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
/* Nama File : BubbleSort.java
Nico G. S. Panjaitan
*/
public class BubbleSort {
public static void main (String[] args) {
if (args.length < 1) {
System.err.println ("Usage:Input form <al1, al2, ...,>");
return;
}
int list[] = new int [args.length];
for (int i = 0; i < args.length; i++){
list[i] = Integer.parseInt(args[i]);
}
for(int i=0; i<list.length; i++){
for(int j=i + 1; j<list.length; j++){
if(list[i] > list[j]){
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
System.out.print("Hasil setelah Bubble Sort: ");
for(int i=0; i<list.length; i++){
System.out.print(list[i] + " " );
}
}
}