public class TestBubble {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a = { 10, 15, 5, 67, 3, 18, 20 };
TestBubble tb = new TestBubble();
tb.bubble(a);
for(int i = 0;i<a.length;i++){
System.out.println(a[i]);
}
}
for (int j=0;j<=i;j++) {
if (a[i] < a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a = { 10, 15, 5, 67, 3, 18, 20 };
TestBubble tb = new TestBubble();
tb.bubble(a);
for(int i = 0;i<a.length;i++){
System.out.println(a[i]);
}
}
public void bubble(int[] a) {
//可一头排,否则就乱了
for (int i = 0; i <= a.length-1; i++) {for (int j=0;j<=i;j++) {
if (a[i] < a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
}