| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 8665 | Accepted: 4172 | 
Description
Input
Output
Sample Input
tarp
given
score
refund
only
trap
work
earn
course
pepper
part
XXXXXX
resco
nfudre
aptr
sett
oresuc
XXXXXX
Sample Output
score
******
refund
******
part
tarp
trap
******
NOT A VALID WORD
******
course
******
Source
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
    int cnt = 0;
    string s;
    set <string> st;
    set <string> :: iterator it;
    while(cin >> s)
    {
        if(s == "XXXXXX")
        {
            cnt ++;
            continue;
        }
        if(cnt == 2)
            break;
        if(cnt == 0)
            st.insert(s);
        else if(cnt == 1)
        {
            bool flag = false;
            sort(s.begin(), s.end());
            do
            {
                it = st.find(s);
                if(it != st.end())
                {
                    flag = true;
                    cout << s << endl;
                }
            }while(next_permutation(s.begin(), s.end()));
            if(!flag)
                printf("NOT A VALID WORD\n");
            printf("******\n");
        }
    }
}版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 1318 Word Amalgamation (字符串 STL大水)
原文地址:http://blog.csdn.net/tc_to_top/article/details/46747795