Demo02.java 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import java.util.Arrays;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title Demo02
  6. * @description
  7. * @create 2026/7/17
  8. */
  9. public class Demo02 {
  10. /*
  11. 1、声明一个数组冒泡排序的方法, bubbleSort(int[] arr) ,在方法中完成数组的排序,并且输出排序后端数组元素
  12. |- 方法声明 public static void bubbleSort(int[] arr){}
  13. |- 创建一个数组,调用方法时候,把数组名传入
  14. int[] myScore={80,85,77,63,84,95,86,88};
  15. 调用方法:
  16. bubbleSort(myScore);
  17. */
  18. public static void bubbleSort(int[] arr){
  19. System.out.println("排序前:"+ Arrays.toString(arr));
  20. //排序代码
  21. System.out.println("排序后:"+ Arrays.toString(arr));
  22. }
  23. // 选择排序
  24. public static void selectionSort(int[] arr){}
  25. //插入排序
  26. public static void insertionSort(int[] arr){}
  27. public static void main(String[] args) {
  28. int[] myScore={80,85,77,63,84,95,86,88};
  29. bubbleSort(myScore);
  30. }
  31. }