Problem Descriptionignatius is so lucky that he met a Martian yesterday. But he didn ' t know the language, the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate, the history book into 中文版. Can you help him?
Inputthe problem have only one test case, the test case consists of the parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should is ignored, then some lines fo Llow, each line contains and strings, the first one is a word in 中文版, the second one is the corresponding word in Mart Ian ' s language. A line with a single string "End" indicates the end of the directory part, and this string should is ignored. The book part starts with a single line contains a string "START", this string should is ignored, then an article written In Martian ' s language. You should translate the article into 中文版 with the dictionary. If you find the word in the dictionary should translate it and write the new Word to your translation if you can ' t Find the word in the "dictionary" is not a translate it, and just copy the old Word to your translation. Space ('), tab (' \ t '), enter (' \ n ') and all the punctuation shouldNot being translated. A line with a single string "End" indicates the end of the book part, and that ' s also the end of the input. All the words is in the lowercase, and each word would contain at most of the characters, and each line would contain at most 3 Characters.
Outputin This problem, you have a to output the translation of the history book.
Sample Input
Startfrom Fiwohello difhmars Riwosfearth fnnvklike fiiwjendstartdifh, i ' m fiwo riwosf.i fiiwj fnnvk! END
Sample Output
Hello, I ' m from the mars.i like earth! This problem with map can be done, learned a map of a function of find. #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <algorithm>using namespace std; #include <map>char s1[100 ],s2[100],s[100],str[5000],str1[100];int Main () {int len,i,j,t;scanf ("%s", s);Map<string,string> Hash;Map<string,string>::iterator it;Hash.clear ();while (scanf ("%s", S1)!=eof){if (strcmp (S1, "END") ==0) break;scanf ("%s", S2);HASH[S2]=S1;}scanf ("%s", s);GetChar ();while (gets (str)){if (strcmp (str, "END") ==0) break;Len=strlen (str);t=0;for (i=0;i<len;i++) {if (str[i]>= ' a ' && str[i]<= ' z ') {str1[t]=str[i];t++;}else{str1[t]= ' + '; t=0;It=hash.find (STR1);if (It!=hash.end ()) {cout<<it->second;}else{printf ("%s", str1);}printf ("%c", Str[i]);}}printf ("\ n");}return 0;}
hdu1075 what is talking about