hdu 1075

来源:互联网 发布:大数据可视化技术综述 编辑:程序博客网 时间:2024/05/22 06:24
#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;}

原创粉丝点击