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
31 lines (23 loc) · 744 Bytes
/
BubbleSort.java
File metadata and controls
31 lines (23 loc) · 744 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
public class BubbleSort{
public static void main (String [] args){
Integer [] tabInt = new Integer[args.length];
for (int i = 0; i < args.length; i++ ){
tabInt[i] = Integer.parseInt(args[i]);
}
int len = tabInt.length;
int temp;
for (int i=0; i < len-1 ; i++){
for (int j= len-1 ; j>0 ; j--){
if (tabInt[j] < tabInt[j-1]){
temp = tabInt[j];
tabInt [j] = tabInt[j-1];
tabInt [j-1] = temp;
}
}
}
for (int i=0;i< len ; i++){
System.out.printf(tabInt[i]+" ");
}
System.out.println();
}
}