package com.p1.cpq1;
/**
*
* @Description
* @author Puiki Email:1115175182@qq.com
* @version
* @date 2021年1月18日下午5:24:03
*
*/
import java.util.Scanner;
public class C1 {
public static void main(String[] args) {
int[] arr = new int[] { -2, -4, -1, 0, 4, 9, 2, 11, 1 };
// 冒泡排序
for (int i = 0; i < arr.length - 1; i++) {
for (int j = 0; j < arr.length - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}
冒泡排序
最新推荐文章于 2022-04-29 23:24:15 发布