hdu 1075 map

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

奇怪的格式

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 }

 

你可能感兴趣的:(map)