HDU1075 What Are You Talking About

本题用到的是STL中的map 函数,,,借助了kuangbin大神的帮助。。。
代码如下,,,自己看吧。

/* HDU 1075 */
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<map>
#include<string.h>
using namespace std;

map<string,string>mp;
int main()
{
    mp.clear();
    string str1,str2;
    cin>>str1;
    while(cin>>str1)
    {
        if(str1=="END")break;
        cin>>str2;
        mp[str2]=str1;
    }
    cin>>str1;
    char ch;
    ch=getchar();
    str1="";
    while(1)
    {
        while(1)
        {
            scanf("%c",&ch);
            if(!((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')))break;
            str1+=ch;
        }
        if(str1=="END")break;
        if(mp.find(str1)==mp.end())cout<<str1;
        else cout<<mp[str1];
        str1="";
        printf("%c",ch);
    }
    return 0;
}

你可能感兴趣的:(STL)