package com.cos.lession08.demo4;
import java.util.Arrays;
/**
* 冒泡排序
*
* @author cos
*
*/
public class MaoPaoDemo {
public static void main(String[] args) {
int[] a = { 65, 54, 87, 23, 42, 77, 55, 15, 88, 99 };
System.out.println(Arrays.toString(a));
for (int i = 0; i < a.length - 1; i++) {
for (int j = 0; j < a.length - 1 - i; j++) {
// 比较 交换 //升序
// if (a[j]<a[j+1]) {//降序
if (a[j] > a[j + 1]) {
int temp = a[j + 1];
a[j + 1] = a[j];
a[j] = temp;
}
}
}
System.out.println(Arrays.toString(a));
}
}