Topic: Define an array, and the elements in it are arranged in order from small to large. After a number is required, insert it into the array according to the original sorting rule.
import java.util.Scanner;
public class ArraySize {
public static void main(String[] args) {
int[] ary = new int[5];
Scanner sc = new Scanner(System.in);
for (int i = 0;i<5;i++) {
ary[i] = sc.nextInt();
}
for (int lun=1; lun<=4; lun++) {
for (int ci=1; ci <= 5-lun; ci++) {
if (ary[ci-1] > ary[ci]){
int x=ary[ci-1];
ary[ci-1]=ary[ci];
ary[ci]=x;
}
}
}
for (int i=0;i<5;i++) {
System.out.print(ary[i]+" ");
}
}
}