Scanner sc = new Scanner(System.in);
System.out.println("请输学生个数");
int count = sc.nextInt();
int [] arr = new int [count];
for (int i = 0; i < arr.length; i++) {
System.out.println("请输入第" + (i+1) + "个");
arr[i] = sc.nextInt();
}
int max = arr[0];
for (int i = 1; i < arr.length; i++) {
if(arr[i] > max)
max = arr[i];
}
System.out.println("最大值为" + max);
从键盘输入n个数,找到其中的最大值
最新推荐文章于 2024-09-10 10:21:38 发布