zoukankan      html  css  js  c++  java
  • Babelfish POJ 2503

    http://acm.hust.edu.cn/vjudge/contest/124435#problem/A

    题意:现有两种语言A, B,每行给出的两个单词分别带别每种语言所对照的写法,两个单词当然是同一个意思。然后给出你一个单词(往后的单词也一定是这种语言下(B)的单词), 让你写出另一种语言(A)相照应的单词。

    题目还是很简单的,前提是你会map函数。。。

    #include<stdio.h>
    #include<iostream>
    #include<math.h>
    #include<queue>
    #include<map>
    #include<string.h>
    #include<algorithm>
    #include<cstdlib>
    using namespace std;
    #define maxn 400
    char a[15],b[15],c[15], maps[100100][15], str[50];
    int n;
    
    
    int main()
    {
        map<string, int>p;
        p.clear();
        map<string, int>q;
        q.clear();
    
        int k=1, i;
    
        while(gets(str),str[0]!=NULL)
        {
            for( i=0; str[i]; i++)
            {
                if(str[i]!=' ')
                    a[i] = str[i];
                else
                {
                    a[i] = '';
                     break;
                }
            }
    
            int j=0;
    
            for(i++; str[i]; i++)
            {
                b[j++]=str[i];
            }
            b[j] = '';
    
            p[a]=k;
            q[b]=k;
            strcpy(maps[k], a);
            k++;
        }
    
        while(scanf("%s", c)!=EOF)
        {
            if(q[c])
            printf("%s
    ",maps[q[c]]);
            else
            printf("eh
    ");
        }
    
        return 0;
    }
    View Code
  • 相关阅读:
    铁轨
    POJ 2385 -- Apple Catching
    POJ 3258 -- River Hopscotch
    POJ 1469 -- COURSES (二分匹配)
    POJ 2349 -- Arctic Network
    最小生成树
    NOIP200703守望者的逃离
    NOIP200706字符串的展开
    POJ 1036 -- Gangsters
    POJ 1952 -- BUY LOW, BUY LOWER
  • 原文地址:https://www.cnblogs.com/daydayupacm/p/5711820.html
Copyright © 2011-2022 走看看