Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class App {
- public static void main(String[] args) throws Exception {
- System.out.println("Quanti vuoi inserire?");
- Scanner scan = new Scanner(System.in);
- int quantity = Integer.parseInt(scan.nextLine());
- int[] values = new int[quantity];
- int max = -1;
- for (int i = 0; i < quantity; i++) {
- while (!scan.hasNextInt()) {
- scan.next();
- System.out.println("Accetto solo numeri.");
- }
- int input = scan.nextInt();
- values[i] = input;
- max = input > max ? input : max;
- }
- System.out.print("I numeri inseriti sono:");
- for (int item : values) {
- System.out.print(item);
- }
- System.out.println("Il piu grande era: " + max);
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement