chillurbrain

13.1. Система регистрации.

May 26th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         String s;
  8.         int n,i;
  9.         HashMap<String,Integer> nm = new HashMap<>();
  10.  
  11.         Scanner sc = new Scanner(System.in);
  12.         n = sc.nextInt();
  13.         for(i=0 ; i< n; i++) {
  14.             s = sc.next();
  15.             if(!nm.containsKey(s)) {
  16.                 System.out.println("OK");
  17.                 nm.put(s,0);
  18.             }
  19.             else {
  20.                 nm.put(s, nm.get(s)+1);
  21.                 System.out.println(s + nm.get(s));
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment