Crazy

Server validation

May 28th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3.  
  4. public class server {
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.  
  11.         HashMap<String, String> hashMap = new HashMap<>();
  12.  
  13.         for (int i =0;i<n;i++)
  14.         {
  15.             String [] niza = scanner.nextLine().split(" ");
  16.  
  17.             String webpage = niza[0];
  18.             String ip = niza[1];
  19.  
  20.             hashMap.put(webpage,ip);
  21.         }
  22.  
  23.         while (scanner.hasNextLine())
  24.         {
  25.             String toCheck = scanner.nextLine();
  26.  
  27.             if (toCheck.equals("END"))
  28.                 break;
  29.  
  30.             System.out.println(hashMap.getOrDefault(toCheck, "Not found"));
  31.  
  32.  
  33.         }
  34.  
  35.  
  36.  
  37.     }
  38. }
  39.  
  40. /*
  41. 3
  42. google.com 64.233.167.99
  43. ebay.com 66.135.192.87
  44. yahoo.com 66.94.234.13
  45. google.com
  46. bing.com
  47. ebay.com
  48. END*/
  49.  
  50. /*
  51.  
  52. 64.233.167.99
  53. Not found
  54. 66.135.192.87*/
Advertisement
Add Comment
Please, Sign In to add comment