public class function { public static void main(String[] args) { //输入数组数据(例如10个) int [] array = inPut(); System.out.println(Arrays.toString(array)); }
/*输入数组数据*/ private static int[] inPut() { int [] array = new int[10]; for(int n=0;n<10;n++){ Scanner scanner = new Scanner(System.in); System.out.print("输入第"+(n+1)+"个数 :"); int n1 = scanner.nextInt(); array [n] = n1; } return array; }}
时间: 2024-10-18 00:13:07