UVa10391

来源:互联网 发布:全国公章大数据平台 编辑:程序博客网 时间:2024/05/14 11:59

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=15&problem=1332&mosmsg=Submission+received+with+ID+11760306

思路很简单,写博客目的是记住find、substr的用法

#include<iostream>#include<set>using namespace std;int main(){    set<string> s;    string temp;    while (cin >> temp)    {        s.insert(temp);    }    for (set<string>::iterator it = s.begin(); it != s.end(); it++)    {        string a = *it;        for (int i = 1; i < a.length(); ++i)        {            if (s.find(a.substr(0, i)) != s.end() && s.find(a.substr(i, a.length() - i)) != s.end())//核心            {                cout << a << endl;                break;            }        }    }}


原创粉丝点击