Language of FatMouse(map,空行处理)

来源:互联网 发布:mac音量键被禁用 编辑:程序博客网 时间:2024/04/30 12:09

C - Language of FatMouse
Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu
Submit Status Practice ZOJ 1109

Description

We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.

Input Specification

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

Output Specification

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

Sample Input

dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Output for Sample Input

catehloops
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <map>#include <string>#include <algorithm>#include <queue>using namespace std;struct node{    char a[15];    int s;};int main(){    char c[15],d[15];    char r[15];    map<string,node >q;    while(1)    {        gets(r);        if(strlen(r) == 0)            break;        sscanf(r,"%s %s",c,d);  q[d].s++;        strcpy(q[d].a,c);    }    char e[15];    while(~scanf("%s",e))    {      if(q[e].s!=0)            {                printf("%s\n",q[e].a);            }            else printf("eh\n");    }    return 0;}



0 0
原创粉丝点击