问题描述:
编写一个程序,输入10个数,确定和打印其中最大数
输入格式:
输入1行,包括10个数
输出格式:
输出1行,输出10个数中的最大数
示例输入:
1 2 3 4 5 6 7 8 9 10
示例输出:
10
50分的代码:
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
int[] arr = new int[10];
for (int i = 0; i < 10; i++) {
arr[i] = Integer.parseInt(line.split(" ")[i]);
}
Arrays.sort(arr);
System.out.println(arr[9]);
}
100分的代码:
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
int[] arr = new int[10];
for (int i = 0; i < 10; i++) {
arr[i] = scanner.nextInt();
}
Arrays.sort(arr);
System.out.println(arr[9]);
}
没有VIP也不知道错在哪了