日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

翻译题(map使用)

發布時間:2024/7/19 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 翻译题(map使用) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

What Are You Talking About

點我

Problem Description Ignatius 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 English. Can you help him? Input The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be 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 are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters. Output In this problem, you have to output the translation of the history book. Sample Input START from fiwo hello difh mars riwosf earth fnnvk like fiiwj END START difh, i'm fiwo riwosf. i fiiwj fnnvk! END Sample Output hello, i'm from mars. i like earth! ? 一道翻譯轉換題,學會了map使用。 1 #include<iostream> 2 #include<map> 3 #include<cstdio> 4 #include<algorithm> 5 #include<string> 6 #include<cstring> 7 using namespace std; 8 int main() 9 { 10 map<string,string>mp; 11 int i=0,j,k; 12 char s1[15],s2[15]; 13 char a[11]; 14 char ch; 15 char buf[15]; 16 // freopen("in.txt","r",stdin); 17 gets(a); 18 while(scanf("%s",s1)) 19 { 20 if(0==strcmp(s1,"END")) 21 break; 22 else 23 { 24 scanf("%s",s2); 25 mp[s2]=s1; 26 } 27 } 28 getchar(); 29 gets(a); 30 while(scanf("%c",&ch)==1) 31 { 32 if(isalpha(ch)) 33 { 34 buf[i++]=ch; 35 } 36 else 37 { 38 buf[i]='\0'; 39 i=0; 40 if(strcmp(buf,"END")==0) 41 break; 42 if(mp.find(buf)!=mp.end()) 43 cout<<mp[buf]; 44 else 45 printf("%s",buf); 46 printf("%c",ch); 47 } 48 49 } 50 return 0; 51 }

?

轉載于:https://www.cnblogs.com/a1225234/p/4548858.html

總結

以上是生活随笔為你收集整理的翻译题(map使用)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。