POJ 2503-babelfish (map)

Source: Internet
Author: User

Title Address: POJ 2503
Test instructions: Enter a dictionary, the dictionary format for "English foreign Language" one by one mapping relationship and then enter several foreign language words, output their English translation words, if the dictionary does not exist in the word, then output "eh".
Idea: Use map to access foreign language and English mapping relationship, and then look good. Note the input format.

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef__int64 LL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-7; Map<string,string>mpCharstr1[ the],str2[ the],str[ the];intMain () {intN Mp.clear (); while(1) {gets (str);if(!strcmp(STR,"")) Break;sscanf(STR,"%s%s", STR1,STR2);    MP[STR2]=STR1; } while(~scanf('%s ', str)) {if(Mp.find (str) ==mp.end ())puts("Eh");Else            printf("%s\n", Mp[str].c_str ());//c_str is directly returning a string ending with/0 and can only be used once. }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

POJ 2503-babelfish (map)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.