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
Latest commit
28 lines (24 loc) · 565 Bytes
/
Copy pathBubbleSort.java
File metadata and controls
28 lines (24 loc) · 565 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
publicclassBubbleSort{
publicstaticvoidmain(String[] args){
intlength = args.length;
int[] arrNum = newint[length];
for(inti=0; i<length; i++){
arrNum[i] = Integer.parseInt(args[i]);
}
sort(arrNum, length);
}
publicstaticvoidsort(intarrNum[], intlength){
for(inta=0; a<length; a++){
for(intb=0; b<length-1; b++){
if(arrNum[b]>arrNum[b+1]){
inttemp = arrNum[b];
arrNum[b] = arrNum[b+1];
arrNum[b+1] = temp;
}
}
}
for(inta=0; a<length; a++){
System.out.print(arrNum[a]+ " ");
}
}
}