冒泡排序
/**
* Created by IntelliJ IDEA.
* Author: 付石强.
* Date: 2017/8/25.
* Time: 下午8:42.
* {2,9,1,4,10,18} 将数组降序输出
*/
public class Array {
public static void main(String[] args) {
int[] array = {2, 9, 1, 4, 10, 18};
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[i] < array[j]) {
int temp =array[i];
array[i] = array[j];
array[j] = temp;
}
}
System.out.println(array[i]);
}
}
}