HDU 1075 What Are You Taking About

字符串转化,模拟过程就做出来了,用了string

#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#define ONLINE
using namespace std;
map<string,string>m;
int main(){
    string a,b;
    cin>>a;
    while(cin>>a&&a!="END"){
        cin>>b;
        m[b]=a;
    }
    char ch[5000];

    getchar();gets(ch);
    while(gets(ch)&&strcmp(ch,"END")){
        b="";
        for(int i=0;i<strlen(ch);i++){
            if(ch[i]<='z'&&ch[i]>='a'){
                b+=ch[i];
            }
            else{
                if(m[b]!="")
                    cout<<m[b];
                else
                    cout<<b;
                putchar(ch[i]);
                b="";
            }
        }
        puts("");
    }
    return 0;
}
---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
原文地址:https://www.cnblogs.com/livelihao/p/5177603.html