|
|
back to boardWhy Crash? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class Example { private static int n; private static String[] commands; private static String m =""; public static void main(String[] args) { try { Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); if(n>=0 && n<=100){ commands = new String[n]; for (int i = 0; i < n; i++) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); commands[i] = in.readLine(); if(commands[i].length()>30 || commands[i].length()==0){ throw new IOException(); } } Arrays.sort(commands); for(String s: commands){ if(s.equals(m)){ System.out.println(s); } else{ m=s; }
} } } catch (IOException e) { }
} } |
|
|