zoukankan      html  css  js  c++  java
  • HDOJ1075字典翻译(map应用)

    #include<iostream>
    #include<cstdio>
    #include<map>
    #include<string>
    #include<cstring>
    using namespace std;
    const int SIZE=10000+16;
    char book[SIZE];
    
    map<string, string> dic;
    
    void fun_in()
    {
        char start[6]={''};
        scanf("%s",start);
        getchar();
        string y;
        while(cin>>y&&y.compare("END"))
        {
            string x;
            cin>>x;
            dic[x]=y;
        }
    }
    
    bool letter(char a)
    {
        if('a'<=a&&a<='z')
            return true;
        return false;
    }
    
    void fun_out()
    {
        char start[6]={''};
        scanf("%s",start);
        getchar();
        while(gets(book)&&strcmp(book,"END")!=0)
        {
            int r=0;
            while(book[r])
            {
                char lett[SIZE]={''};
                int l=0;
                while(letter(book[r])&&book[r])
                {
                    lett[l++]=book[r++];
                }
                
                string k=lett;
                if(dic.find(k)!=dic.end())
                {
                    cout<<dic[k];
                }
                else
                {
                    cout<<lett;    
                }
                
                char fu[SIZE]={''};
                l=0;
                while(!letter(book[r])&&book[r])
                {
                    fu[l++]=book[r++];
                }
                
                k=fu;
                if(dic.find(k)!=dic.end())
                {
                    cout<<dic[k];
                }
                else
                {
                    cout<<fu;    
                }
                
            }
            printf("
    ");        
        }
        
    }
    
    int main()
    {
        fun_in();
        fun_out();
        
        return 0;
    }
  • 相关阅读:
    12-29 批量删除
    12-29 注册审核
    12-25造数据库面向对象
    12-23 会话保持
    2016-12-19 php修改数据库数据
    12-18数据访问
    12-16php测试题
    1027 制作表格
    1027 超链接
    1027 HTML
  • 原文地址:https://www.cnblogs.com/program-ccc/p/4700609.html
Copyright © 2011-2022 走看看