随笔 - 127,  文章 - 0,  评论 - 0,  阅读 - 25384

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] = '\0';
                 break;
            }
        }

        int j=0;

        for(i++; str[i]; i++)
        {
            b[j++]=str[i];
        }
        b[j] = '\0';

        p[a]=k;
        q[b]=k;
        strcpy(maps[k], a);
        k++;
    }

    while(scanf("%s", c)!=EOF)
    {
        if(q[c])
        printf("%s\n",maps[q[c]]);
        else
        printf("eh\n");
    }

    return 0;
}
View Code
复制代码

 

posted on   不忧尘世不忧心  阅读(138)  评论(0编辑  收藏  举报

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示