import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); if (n == 0) { break; } List<String> list = new ArrayList<>(); while (n-- > 0) { list.add(scanner.next()); } List<String> res = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { String str=list.get(i); if (str.endsWith(".exe")) { String substring = str.substring(0, str.length() - 4); if (list.contains(substring)) { res.add(str); } } } Collections.sort(res); res.forEach(System.out::println); } } } |
Double click to view unformatted code.