| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
javaimport java.util.Scanner;
import java.util.Hashtable;
public class poj2503{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Hashtable< String,String> table = new Hashtable< String, String>();
String input;
String [] array=new String[2];
while(sc.hasNext()){
input=sc.nextLine();
if(input.length()==0) {break;}
array=input.split(" ");
table.put(array[1],array[0]);//put() 的作用是对外提供接口,让Hashtable对象可以通过put()将“key-value”添加到Hashtable中。
}
while(sc.hasNext()){
input=sc.nextLine();
if(table.get(input)!=null) {
System.out.println(table.get(input));}//get() 的作用就是获取key对应的value,没有的话返回null
else {System.out.println("eh");}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator