数组插入数据排序
package day05;
import java.util.Scanner;
public class demo5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] arr = new int[]{12, 14, 23, 45, 66, 68, 70, 77, 90, 91};
int[] newArr = new int[11];
int index = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < num) {
newArr[i] = arr[i];
index++;
} else {
newArr[i + 1] = arr[i];
}
}
newArr[index] = num;
for (int i1 = 0; i1 < newArr.length; i1++) {
System.out.print(newArr[i1] + " ");
}
}
}