Babelfish (map 用法。<string, string>

Babelfish

-

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and
a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Sample Output

cat
eh
loops
#include<cstdio>
#include<cstring>
#include<map>
#include<string>

using namespace std;

map<string, string> ma;
map<string, string>::iterator it;

char str1[11], str2[11], str[22];
int main(){
    while(gets(str) && str[0]){
        sscanf(str,"%s%s", str1, str2);
        ma[str2] = str1;
    }
    while(scanf("%s", str1) != EOF){
        it = ma.find(str1);                 //  用于查找,查找,茶渣
        if(it == ma.end()) printf("eh\n");
        else printf("%s\n", it->second.c_str());
    }
    return 0;
}

时间: 2024-12-23 11:31:49

Babelfish (map 用法。<string, string>的相关文章

POJ2503——Babelfish(map映射+string字符串)

Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 diction

List&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt; 开启 Map&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt;

将List变成Map结构体,下面的文字是没有水平! 写作方法传送前土壤很长一段时间.我不知道有没有好的解决办法.我们也希望提供! Map<String, String> map1 = new HashMap<String, String>(); map1.put("a", "1"); map1.put("b", "3"); map1.put("c", "5");

Struts2标签遍历List&lt;Map&lt;String, String&gt;&gt;

import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.opensymphony.xwork2.ActionSupport; public class LoginAction extends ActionSupport { private List<Map<String, String>> list; @Override

Map&lt;String, String&gt;的数据处理以及ListView的适配器

Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); //第一种:普遍使用,二次取值 System.out.println("通过Ma

原型模式 private static Map&lt;String,Prototype&gt; map = new HashMap&lt;String,Prototype&gt;();

public class PrototypeManager { /** * 用来记录原型的编号和原型实例的对应关系 */ private static Map<String,Prototype> map = new HashMap<String,Prototype>(); /** * 私有化构造方法,避免外部创建实例 */ private PrototypeManager(){} /** * 向原型管理器里面添加或是修改某个原型注册 * @param prototypeId 原型编

Map&lt;String,List&lt;String&gt;&gt;转为List&lt;Map&lt;String,String&gt;&gt;

/**  *   * @param map  输入  * @param list 输出  * @param idx     次序  * @param pathMap 已选  */ void map2List(Map<String, List<String>> map, List<Map<String, String>> list,                                     int idx, HashMap<String,S

Map&lt;String,String&gt;转换json字符串

文前一注:注意jar包的导入和引入. 下面是代码实现: 1 import java.util.HashMap; 2 import java.util.Map; 3 import net.sf.json.JSONObject; 4 5 public class testJson { 6 7 public static void main(String[] args) { 8 testPingping(); 9 } 10 //里面的任务都是我的好友,希望他们不要看到 ^_^^_^^_^ 11 pub

List&lt;Map&lt;String, String&gt;&gt; 转 Map&lt;String, List&lt;String&gt;&gt;

将List转成Map结构,以下为没有水平的写法! 好久之前写的土方法转换,不知道有没有优秀的解法,还希望大家提供! Map<String, String> map1 = new HashMap<String, String>(); map1.put("a", "1"); map1.put("b", "3"); map1.put("c", "5"); Map<

map&lt;String ,String&gt; 自动排序 升序

//TreeMap自动排序 Map<String, String> params = new TreeMap<String, String>( new Comparator<String>() { public int compare(String obj1, String obj2) { // 升序排序 return obj1.compareTo(obj2); } });