|
|
вернуться в форумWhy Crash? import java.util.Scanner; public class Example { private static int n; private static String[] penguin; private static int[] myCount = {1, 1, 1}; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); if(n>=1 && n<=1000){ scanner = new Scanner(System.in); penguin = new String[n]; for (int i = 0; i < n; i++) { penguin[i] = scanner.nextLine(); if (penguin[i].equals("Emperor Penguin")) { myCount[0]++; }else if (penguin[i].equals("Little Penguin")) { myCount[1]++; }else if (penguin[i].equals("Macaroni Penguin")) { myCount[2]++; } } if(myCount[0]>myCount[1]){ if(myCount[0]>myCount[2]){ System.out.println("Emperor Penguin"); }else{ System.out.println("Macaroni Penguin"); } }else if(myCount[1]>myCount[2]){ System.out.println("Little Penguin"); }else{ System.out.println("Macaroni Penguin"); }
} } } |
|
|