Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class server {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- HashMap<String, String> hashMap = new HashMap<>();
- for (int i =0;i<n;i++)
- {
- String [] niza = scanner.nextLine().split(" ");
- String webpage = niza[0];
- String ip = niza[1];
- hashMap.put(webpage,ip);
- }
- while (scanner.hasNextLine())
- {
- String toCheck = scanner.nextLine();
- if (toCheck.equals("END"))
- break;
- System.out.println(hashMap.getOrDefault(toCheck, "Not found"));
- }
- }
- }
- /*
- 3
- google.com 64.233.167.99
- ebay.com 66.135.192.87
- yahoo.com 66.94.234.13
- google.com
- bing.com
- ebay.com
- END*/
- /*
- 64.233.167.99
- Not found
- 66.135.192.87*/
Advertisement
Add Comment
Please, Sign In to add comment