Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- *
- * @author Usuario
- */
- public class P291 {
- Scanner in;
- public boolean caso() {
- int numParrafos = Integer.parseInt(in.nextLine());
- if (numParrafos == 0) {
- return false;
- }
- Map<String, String> m = new TreeMap<>();
- for (int i = 1; i <= numParrafos; i++) {
- String parrafo = in.nextLine().toLowerCase();
- String[] a = parrafo.split(" ");
- for (int j = 0; j < a.length; j++) {
- if (a[j].length() > 2) {
- if (m.containsKey(a[j]) ) {
- if (!m.get(a[j]).equals("" + i)) {
- String lineas = m.get(a[j]) + " " + i;
- m.put(a[j], lineas);
- }
- } else {
- m.put(a[j], "" + i);
- }
- }
- }
- }
- for (String p : m.keySet()) {
- System.out.format("%s %s%n", p, m.get(p));
- }
- System.out.println("---");
- return true;
- }
- public void run() {
- in = new Scanner(System.in);
- while (caso());
- }
- public static void main(String[] args) {
- // TODO code application logic here
- new P291().run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement