hdu What Are You Talking About(map)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075

 

map简单应用

 

代码:

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <ctype.h>
 7 #include <iomanip>
 8 #include <queue>
 9 #include <map>
10 #include <stdlib.h>
11 using namespace std;
12 
13 int main()
14 {
15     char b[12],s1[12],s2[12],ch;
16     map<string,string> mp;
17     int d=0;
18     gets(b);
19     while(scanf("%s%s",s1,s2),strcmp(s1,"END")){
20         mp[s2]=s1;
21     }
22     getchar();
23     while(scanf("%c",&ch)){
24         if(isalpha(ch))
25             b[d++]=ch;
26         else{
27             b[d]='\0';d=0;
28             if(strcmp(b,"END")==0)
29                 break;
30             if(mp.find(b)!=mp.end())
31                 cout<<mp[b];
32             else
33                 printf("%s",b);
34             putchar(ch);
35         }
36     }
37 }

map学习链接:http://www.cnblogs.com/tianfang/archive/2006/12/30/607859.html

                    http://blog.csdn.net/yu_yuan_1314/article/details/9794435

                    http://blog.csdn.net/sanwenyublog/article/details/18006749

posted @ 2015-10-12 15:05  Vmetrio  阅读(252)  评论(0编辑  收藏  举报