- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- vector<string> v;
- int main()
- {
- int size, i;
- string str, temp;
- while (cin >> str)
- {
- if (str == "XXXXXX") break;
- v.push_back(str);
- }
- sort(v.begin(), v.end());
- bool flag;
- size = v.size();
- while (cin >> str)
- {
- if (str == "XXXXXX") break;
- sort(str.begin(), str.end());
- flag = false;
- for (i = 0; i < size; i++)
- {
- temp = v[i];
- sort(temp.begin(), temp.end());
- if (temp == str)
- {
- flag = true;
- cout << v[i] << endl;
- }
- }
- if (flag)
- cout << "******" << endl;
- else
- cout << "NOT A VALID WORD" << endl << "******" << endl;
- }
- return 0;
- }
poj 1318 Word Amalgamation
最新推荐文章于 2016-07-24 23:59:03 发布