package day01;
import java.util.Scanner;
public class maopao {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = { 99, 85, 43, 63, 60,23 };
System.out.println("请输入新增数字");
int num = sc.nextInt();
int[] arr1 = new int[arr.length + 1];
System.arraycopy(arr, 0, arr1, 0, arr.length);
arr1[arr.length] = num;
for (int j : arr1) {
System.out.print(j + " ");
}
System.out.println();
int tem;
for (int y = 0; y < arr1.length-1; y++) {
for (int j = 0; j < arr1.length-1; j++) {
if (arr1[j] < arr1[j + 1]) {
tem = arr1[j];
arr1[j] = arr1[j+1];
arr1[j+1] = tem;
}
}
}
for (int x : arr1) {
System.out.print(x+" ");
}
}
}
数组中新增数字并且降序排序 冒泡排序方法
最新推荐文章于 2024-11-04 17:05:06 发布