测试

xiaoxiao2021-02-28  7

冒泡排序练习

int[] a = new int[]{3,5,2,7,4}; for (int i=0;i<a.length-1;i++){ for (int j=a.length-2;j>=i;j--){ if (a[j]>a[j+1]){ int temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } } for (int k:a){ System.out.println(k); }
转载请注明原文地址: https://www.6miu.com/read-2250134.html

最新回复(0)