Java实现由小到大冒泡排序
作者:互联网
1 public class Paixu { 2 public static void main(String args[]) { 3 int myNum[] = {2,6,4,1,5}; 4 //从小到大排序: 5 int tempNum=0; 6 for(int i=0;i<5;i++) { 7 for (int j=i+1;j<5;j++) { 8 if(myNum[i]>myNum[j]) { 9 tempNum=myNum[i]; 10 myNum[i]=myNum[j]; 11 myNum[j]=tempNum; 12 } 13 } 14 } 15 for(int a:myNum) { 16 System.out.println(a); 17 } 18 } 19 }
标签:Java,int,tempNum,冒泡排序,由小到大,myNum,public 来源: https://www.cnblogs.com/rainbow-1/p/16123214.html