hdu 1075 What Are You Talking About map

#include<bits/stdc++.h>
using namespace std;

map<string,string>m;
char s[500],str[3005];

int main()
{
    int i,j,len;
    string st1,st2;
    string END="END";
    while(~scanf("%s",s))
    {
        m.clear();
        while(cin>>st1)
        {
            if(st1.compare(END)==0) break;
            cin>>st2;
            m[st2]=st1;
        }
        cin>>st1;
        char c=getchar();
        while(gets(str)&&strcmp(str,"END")!=0)
        {
            //if(strcmp(str,"START")==0) continue;
            st2="";
            j=0;
            len=strlen(str);
            for(i=0;i<len;i++)
            {
                if('a'<=str[i]&&str[i]<='z')
                {
                    s[j++]=str[i];
                }
                else
                {
                    s[j]=0;
                    j=0;
                    st1=s;
                    if(m.find(st1)==m.end()) st2+=st1;
                    else st2+=m[st1];
                    st2+=str[i];
                }
            }
            st2+="\n";
            cout<<st2;
        }
    }
    return 0;
}

你可能感兴趣的:(hdu 1075 What Are You Talking About map)