-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathBubblesort.java
More file actions
35 lines (30 loc) · 821 Bytes
/
Bubblesort.java
File metadata and controls
35 lines (30 loc) · 821 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
package job5.latihanBubblesort;
public class Bubblesort {
public int[] data;
public int jmDt;
public Bubblesort(int Data[], int jmlDt){
jmDt=jmlDt;
data = new int[jmlDt];
for(int i=0; i<jmlDt; i++){
data[i]=Data[i];
}
}
public void sortData(){
int temp=0;
for(int i=0; i<jmDt;i++){
for(int j=1; j<(jmDt-i);j++){
if(data[j-1]>data[j]){
temp = data[j];
data[j]= data[j-1];
data[j-1]= temp;
}
}
}
}
public void tampilkanData(){
for(int i=0;i<jmDt;i++){
System.out.print(data[i] + " ");
}
System.out.println("");
}
}