小程序--冒泡排序

//冒泡排序:相邻两个比较,选出最大的往后放
class Alhh{
public static void main(String[] args){
int[] m=new int[]{-3,12,4,15,-99};
for(int i=0;i for(int j=0;j if(m[j]>m[j+1]){
int temp=m[j];
m[j]=m[j+1];
m[j+1]=temp;
}
}

}
for(int i=0;i System.out.print(m[i]+"\t");
}
}
}

转载于:https://www.cnblogs.com/alhh/p/5287687.html

你可能感兴趣的:(小程序--冒泡排序)