package com;
/**
* 实现冒泡排序
* @author 小小王
*
*/
public class TestBubbleSort {
public static void bubbleSort(int[] a){
int temp = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++) {
if(a[j] < a [i]){
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
}
public static void main(String[] args) {
int a[] = {4,6,2,4,8,5,2,9};
bubbleSort(a);
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
}
}
/**
* 实现冒泡排序
* @author 小小王
*
*/
public class TestBubbleSort {
public static void bubbleSort(int[] a){
int temp = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++) {
if(a[j] < a [i]){
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
}
public static void main(String[] args) {
int a[] = {4,6,2,4,8,5,2,9};
bubbleSort(a);
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
}
}