您的位置:首页 > 其它

hdu 1075

2013-10-27 11:58 134 查看
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

string s1;
string s2;

int judge(char ch)
{
    if(ch >= 'a' && ch <= 'z')
        return 1;
    else
        return 0;
}

int main()
{
    map<string, string>m;

    while(cin>>s1)
    {
        if(s1 == "START")
            continue;
        if(s1 == "END")
            break;
        cin>>s2;
       m[s2] = s1;
    }
    getchar();
   map<string, string>::iterator it;

     while(getline(cin,s1))
    {
        if(s1 == "START")
            continue;
        if(s1 == "END")
          break;
        int len = s1.length();
        string s3 = "";
        for(int i = 0; i < len; i++)
        {
            if(judge(s1[i]))
            {
                s3 += s1[i];
            }
            else
            {
                it = m.find(s3);
                if(it != m.end())
                    cout<<m[s3];
                else
                    cout<<s3;
                s3 = "";
                cout<<s1[i];
            }
        }
        printf("\n");

    }

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: