冒泡排序
public class maopao { public static void main(String[] args) { //冒泡排序 int[]array={12,22,13,44,11,33}; for(int i=0;i<array.length;i++){ System.out.print(array[i]+"\t"); } System.out.println(); for(int j=0;j<array.length-2;j++){ for(int i=0;i<array.length-1;i++){ if(array[i]<array[i+1]){//改变"<"">"来改变由大到小,由小到大 int t=array[i]; array[i]=array[i+1]; array[i+1]=t; } } for(int i=0;i<array.length;i++){ System.out.print(array[i]+"\t"); } System.out.println(); } } }