1 개요[ | ]
- HR자바 Java Map
Java
Copy
//Complete this code or write your own from scratch
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh)
{
Scanner in = new Scanner(System.in);
int n=in.nextInt();
in.nextLine();
HashMap<String, Integer> phoneBook = new HashMap<String, Integer>();
for(int i=0;i<n;i++)
{
String name=in.nextLine();
int phone=in.nextInt();
in.nextLine();
phoneBook.put(name, phone);
}
while(in.hasNext())
{
String s=in.nextLine();
if( !phoneBook.containsKey(s)) {
System.out.println("Not found");
continue;
}
System.out.println(s + "=" + phoneBook.get(s));
}
}
}
2 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.