码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1075 map

时间:2015-04-17 01:08:19      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

题意:给一个字典,和一句话,翻译一下

奇怪的格式

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!
 1 #include<cstdio>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<queue>
 7 #include<map>
 8 using namespace std;
 9 #define MOD 1000000007
10 const double eps=1e-5;
11 #define cl(a) memset(a,0,sizeof(a))
12 #define ts printf("*****\n");
13 const int MAXN=1005;
14 map<string,string> mp;
15 int n,m,tt;
16 int main()
17 {
18     int i,j,k;
19     #ifndef ONLINE_JUDGE
20     freopen("1.in","r",stdin);
21     #endif
22     string str1,str2;
23     cin>>str1;
24     while(cin>>str1)
25     {
26         if(str1=="END") break;
27         cin>>str2;
28         mp[str2]=str1;
29     }
30     cin>>str1;
31     char ch;
32     ch=getchar();
33     str1="";
34     while(1)
35     {
36         while(1)
37         {
38             scanf("%c",&ch);
39             if(!((ch>=a&&ch<=z)||(ch>=A&&ch<=Z)))   break;
40             str1+=ch;
41         }
42         if(str1=="END") break;
43         if(mp.find(str1)==mp.end()) cout<<str1;    //并未在字典中找到
44         else cout<<mp[str1];
45         str1="";
46         printf("%c",ch);    //符号或空格
47     }
48     return 0;
49 }

 

hdu 1075 map

标签:

原文地址:http://www.cnblogs.com/cnblogs321114287/p/4433702.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!