1 public static void main(String[] args) { 2 int arr[] = new int[5]; 3 System.out.println("请输入5个数字"); 4 Scanner input = new Scanner(System.in); 5 for (int i = 0; i < arr.length; i++) 6 arr[i] = input.nextInt(); 7 int max = arr[0]; 8 int s = 0; 9 for (int i = 1; i < arr.length; i++) { 10 if (max < arr[i]) { 11 max = arr[i]; //确定最大值 12 s = i; //确定最大值下标位置 13 } 14 } 15 System.out.println("最大值是第" + (s + 1) + "位"); 16 17 }