public class study {
@Test
// 冒泡排序
public void test1(){
int[] array = {40,17,21,1};
for (int i = 1; i <= array.length-1 ; i++) {
for (int j = 0; j < array.length-i; j++) {
if (array[j] > array[j+1] ){
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
for (int i = 0; i <= array.length-1; i++) {
System.out.println(array[i]);
}
}
}
冒泡排序。。。
最新推荐文章于 2024-09-10 10:21:38 发布