import java.util.LinkedHashMap;
import java.util.Scanner;
import java.util.Map.Entry;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedHashMap hashmap = new LinkedHashMap<String, String>();
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String b = "";
String t = in.next();
if (t.equals("code"))
continue;
if (t.contains("_")) {
String[] str = t.split("_");
String hanzi = str[0];
String pinyin = str[1];
hashmap.put(hanzi, pinyin);
continue;
}
if (t.equals("search"))
continue;
int num = 0;
int count = 0;
for (int i = 0; i < t.length(); i++)
if (t.charAt(i) >= '0' && t.charAt(i) <= '9') {
num = t.charAt(i) - '0';
t = t.substring(0, i);
// System.out.println(num);
}
for (Object o : hashmap.entrySet()) {
Entry entry = (Entry) o;
String key = (String) entry.getKey();
String value = (String) entry.getValue();
if (value.equals(t)) {
count++;
if (count < 6 && num == 0) {
b += key + ";";
// System.out.print(key+";");
} else if (count == num) {
System.out.print(key);
}
}
}
if (count == 0 || num > count) {
System.out.print("Error");
} else if (b.length() >= 1) {
System.out.println(b.substring(0, b.length() - 1));
}
}
}
}
输入法查找—JAVA
最新推荐文章于 2024-06-24 17:42:51 发布