| ||||||||||
| 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 | |||||||||
太美妙了。。。用Java做连异常处理都用上了。。。呵呵/*
Author: sgxiao
Title: 2503 -- Babelfish
LANG: java
Date : Sun Sep 7 15:23:00 CST 2008
*/
import java.util.*;
import java.math.*;
import java.util.regex.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<String, String> dictionary = new HashMap<String, String>();
String eng;
String niaoyu;
String search;
while(scanner.hasNextLine() ) {
String nextline = scanner.nextLine();
eng = nextline.split(" ")[0];
try {
niaoyu = nextline.split(" ")[1];
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
search = eng;
break;
}
dictionary.put(niaoyu, eng);
}
while(scanner.hasNext()) {
search = scanner.next();
String result;
if( (result = dictionary.get(search)) != null) {
System.out.println(result);
} 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