Java-Übungen auf einer bestimmten Site. Ein Memo des Programms, das die Ganzzahl n als Standardeingabe eingibt, dann n beliebige numerische Werte eingibt und den Maximalwert daraus ausgibt.
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//Geben Sie die Ganzzahl n ein
int num = sc.nextInt();
int max = 0;
int[] array = new int[num];
//Geben Sie eine beliebige Zahl n-mal ein
for(int i = 0; i < num; i++){
array[i] = sc.nextInt();
if(max < array[i]){
max = array[i];
}
}
System.out.println(max);
}
}
Recommended Posts