| 123456789101112131415161718192021222324252627282930313233 |
- import java.util.Arrays;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo02
- * @description
- * @create 2026/7/17
- */
- public class Demo02 {
- /*
- 1、声明一个数组冒泡排序的方法, bubbleSort(int[] arr) ,在方法中完成数组的排序,并且输出排序后端数组元素
- |- 方法声明 public static void bubbleSort(int[] arr){}
- |- 创建一个数组,调用方法时候,把数组名传入
- int[] myScore={80,85,77,63,84,95,86,88};
- 调用方法:
- bubbleSort(myScore);
- */
- public static void bubbleSort(int[] arr){
- System.out.println("排序前:"+ Arrays.toString(arr));
- //排序代码
- System.out.println("排序后:"+ Arrays.toString(arr));
- }
- // 选择排序
- public static void selectionSort(int[] arr){}
- //插入排序
- public static void insertionSort(int[] arr){}
- public static void main(String[] args) {
- int[] myScore={80,85,77,63,84,95,86,88};
- bubbleSort(myScore);
- }
- }
|