Untitled
unknown
plain_text
2 years ago
861 B
3
Indexable
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class PhoneBook {
public static void main(String[] args) {
Map<String, Integer> phonebookMap = new HashMap<>();
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
for (int i = 0;i < n; i++){
String name = sc.nextLine();
int number = sc.nextInt();
sc.nextLine();
phonebookMap.put(name, number);
}
while (sc.hasNext()){
String person = sc.nextLine();
if (phonebookMap.containsKey(person)){
System.out.println(person + "=" + phonebookMap.get(person));
}else {
System.out.println("Not found");
}
}
sc.close();
}
}
Editor is loading...
Leave a Comment