Professional Documents
Culture Documents
Contoh 1.1 Source Code Java Bubble Sort: Import Public Class Bubblesort Public Static Void
Contoh 1.1 Source Code Java Bubble Sort: Import Public Class Bubblesort Public Static Void
F -X C h a n ge
W
N
O
y
bu
try {
String mtd= scanKata.next();
mtdSort= Integer.parseInt(mtd);
}
catch (Exception e){
mtdSort= 3;
}
System.out.println("");
switch (mtdSort) {
case 1:
int count= 1;
System.out.println ("# Data Awal :");
for (int i = 0; i < input; i++){
if (i == input-1){
System.out.println(tInput[i]+"\n");
}
ac
.c
tr
om
k
lic
C
om
k
lic
C
.c
re
k e r- s o ft w a
ac
ww
ww
tr
to
to
bu
N
O
PD
PD
k e r- s o ft w a
re
F -X C h a n ge
F -X C h a n ge
W
y
bu
System.out.print(tInput[i]+" ");
}
}
for (int x = 0; x 0; y--) {
if (tInput[y].compareToIgnoreCase(tInput[y-1])<0) {
String temp = tInput[y];
tInput[y] = tInput[y-1];
tInput[y-1] = temp;
}
}
if (count < input-1) {
System.out.println ("# Proses ke-"+count+" :");
}
else if (count == input-1) {
System.out.println("# Hasil Sorting :");
}
for (int i = 0; i < input; i++) {
if (i == input-1) {
System.out.println (tInput[i]+"\n");
}
else {
System.out.print(tInput[i]+" ");
}
}
count++;
}
break;
case 2:
count= 1;
System.out.println ("# Data Awal :");
for (int i = 0; i < input; i++){
if (i == input-1){
System.out.println(tInput[i]+"\n");
}
else {
System.out.print(tInput[i]+" ");
}
}
for (int x = 0; x 0; y--) {
ac
.c
tr
om
to
k
lic
C
k
lic
C
.c
re
k e r- s o ft w a
ac
om
to
bu
else {
ww
ww
tr
N
O
N
O
PD
PD
k e r- s o ft w a
re
F -X C h a n ge
F -X C h a n ge
W
y
bu
ac
.c
tr
om
to
k
lic
C
k
lic
C
.c
re
k e r- s o ft w a
ac
om
to
bu
if (tInput[y].compareToIgnoreCase(tInput[y-1])>0) {
ww
ww
tr
N
O
N
O
PD
PD
k e r- s o ft w a
re