简单的冒泡排序

xiaoxiao2021-02-28  70

public static void maopao() { int a[] = { 1, 2, 4, 7, 3, 5, 6 }; 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]){ int tem=a[j+1]; a[j+1]=a[j]; a[j]=tem; } } } for (int j = 0; j < a.length; j++) { System.out.print(a[j]); } }
转载请注明原文地址: https://www.6miu.com/read-96817.html

最新回复(0)