zoukankan      html  css  js  c++  java
  • 【POJ】[2503]Babelfish

    Babelfish

    Time Limit: 3000MS Memory Limit: 65536K
    Total Submissions: 40481 Accepted: 17238

    Description

    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
    

    Hint

    Huge input and output,scanf and printf are recommended.
    简单的STL应用,可用map+string水过读取字典的时候可用c=getchar()读取然后判断是否为‘ ’来控制结束如果不是则继续把串读取完再合并起来
    
    
    #include<stdio.h>
    #include<map>
    #include<string>
    #include<algorithm>
    using namespace std;
    char s1[12],s2[12];
    int main() {
    	map<string,string>q;
    	char c;
    	while(c=getchar(),c!='
    ')	{
    		scanf("%s %s",s1,s2);
    		getchar();
    		string t1=s1;
    		s1[0]=c,s1[1]='';
    		t1=s1+t1;
    		string t2=s2;
    		q[t2]=t1;
    	}
    	while(scanf("%s",s1)!=EOF) {
    		string res=q[s1];
    		if(res.length()>0)
    			printf("%s
    ",res.c_str());
    		else
    			printf("eh
    ");
    	}
    	return 0;
    }
    


    
    
    
    
    
    
    
    
    题目地址:【POJ】[2503]Babelfish
    查看原文:http://www.boiltask.com/blog/?p=1443
  • 相关阅读:
    namespace std 定义的位置
    [Struts]学习日记3 在页面中显示条目列表
    [Hibernate]关于ID的一个容易混淆的地方
    [Struts]"Cannot find bean in any scope"之一解
    [Struts]HibernatePlugIn for Struts(转贴)
    日志搬家了!
    [Struts]学习日记2 增加一些验证
    实验室的项目 讨论
    Struts常见异常信息和解决方法
    参加婚礼
  • 原文地址:https://www.cnblogs.com/BoilTask/p/12569465.html
Copyright © 2011-2022 走看看