zoukankan      html  css  js  c++  java
  • [POJ2503]Babelfish

    题目链接:http://poj.org/problem?id=2503

     
     

    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.

    Source

    STL撸过,重要的是输入的处理。

     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <cstring>
     4 #include <algorithm>
     5 #include <iostream>
     6 #include <cmath>
     7 #include <queue>
     8 #include <map>
     9 #include <stack>
    10 #include <list>
    11 #include <vector>
    12 #include <cctype>
    13 
    14 using namespace std;
    15 
    16 typedef map<string, string> mss;
    17 typedef pair<string, string> pss;
    18 mss dic;
    19 pss tmp;
    20 char a[110];
    21 char b[110];
    22 char buf[80];
    23 
    24 int main() {
    25     // freopen("in", "r", stdin);
    26     // ios::sync_with_stdio(false);
    27     while(gets(buf)) {
    28         int flag = 0;
    29         int cnt = 0;
    30         int sflag = 0;
    31         for(int i = 0; buf[i]; i++) {
    32             if(flag) {
    33                 if(sflag && buf[i] == ' ') {
    34                     continue;
    35                 }
    36                 b[cnt++] = buf[i];
    37             }
    38             else {        
    39                 if(buf[i] != ' ') {
    40                     a[cnt++] = buf[i];
    41                     sflag = 1;
    42                 }
    43                 else {
    44                     flag = 1;
    45                     cnt = 0;
    46                 }
    47             }
    48         }
    49         tmp = make_pair(b, a);
    50         dic.insert(tmp);
    51         if(!flag) {
    52             break;
    53         }
    54         memset(a, 0, sizeof(a));
    55         memset(b, 0, sizeof(b));
    56         memset(buf, 0, sizeof(buf));
    57     }
    58     // for(mss::iterator it = dic.begin(); it != dic.end(); it++) {
    59     //     cout << it->first << " " << it->second << endl;
    60     // }
    61     while(~scanf("%s", buf)) {
    62         if(dic.find(buf) != dic.end()) {
    63             // cout << dic[buf] << endl;
    64             printf("%s
    ", dic[buf].data());
    65         }
    66         else {
    67             printf("eh
    ");
    68         }
    69     }
    70     return 0;
    71 }
  • 相关阅读:
    NO17--vue父子组件间单向数据流的解决办法
    NO--16 vue之父子组件传值
    使用Element-ui开发桌面应用的小问题
    微信小程序右到左联动
    微信小程序左到右联动
    微信小程序选项卡之跳转
    微信小程序
    回调函数和钩子函数的说明
    最近项目中遇到了一个场景,其实很常见,就是定时获取接口刷新数据。那么问题来了,假设我设置的定时时间为1s,而数据接口返回大于1s,应该用同步阻塞还是异步?
    组件的相互嵌套slot内容分发
  • 原文地址:https://www.cnblogs.com/kirai/p/4761435.html
Copyright © 2011-2022 走看看