HDU 1075 What Are You Talking About

http://acm.hdu.edu.cn/showproblem.php?pid=1075

趁着HDOJ活了赶快交一个、、、刚开始学习STL的应用,这个代码学习自sx老祖。。。

View Code
#include <stdio.h> 
#include <iostream> 
#include <string> 
#include <map>
using namespace std; 
int main()
{
    int i; 
    char str[3001];
    map <string,string> M;
    string str1,str2; 
    cin >> str1; 
    while(1)
    {
        cin >> str1; 
        if(str1=="END")break; 
         cin >> str2;
        M[str2]=str1; 
    } 
    cin >> str1;
    gets(str); 
    str1=""; 
    while(1)
    {
        gets(str); 
        if(strcmp(str,"END")==0)break; 
        for(i=0;str[i];i++)
        { 
            if(str[i]>='a'&&str[i]<='z')
                str1+=str[i];
            else
            {
                if(M[str1]!="")cout << M[str1];
                else cout << str1;
                str1="";
                printf("%c",str[i]);
            }
        }
        putchar('\n'); 
        str1=""; 
    } 
    return 0;
}
原文地址:https://www.cnblogs.com/xiaohongmao/p/2494109.html