uva 123 stl大法好

来源:互联网 发布:fm2016苏亚雷斯数据 编辑:程序博客网 时间:2024/05/29 18:45
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <ctype.h>


using namespace std;
set<string> list;
multimap<string, string> ans;


int main()
{
    string s;
    string line;
    list.clear();
    ans.clear();


    while(getline(cin,s))
    {
        if(s == "::")
            break;
        for( int i = 0; s[i] != '\0'; i++)
            s[i] = tolower(s[i]);
        list.insert(s);
    }


    while(getline(cin,line))
    {
        
        for( int i = 0; i<line.size(); i++)
            line[i] = tolower(line[i]);
        for( int i = 0; i < line.size(); i++)
        {
            if(!isalpha(line[i]))
                continue;


            string str;
            int j = i;


            while(isalpha(line[j]))
            {
                str += line[j];
                j++;
            }


            if(!list.count(str))
            {
                for( int k =0; str[k] != '\0'; k++)
                    str[k] = toupper(str[k]);
                string str3 = line;
                str3.replace(i, str.size(), str);
                ans.insert(make_pair(str, str3));
            }
            i = j;
        }


    }
    map<string,string> :: iterator  it = ans.begin();
    for( ; it != ans.end(); it++)
        cout<<it->second<<endl;
    return 0;




}
0 0
原创粉丝点击