📄 1113.cpp
字号:
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
void main(){
vector<string> dic;
while(true){
string word;
cin >> word;
if (word == "XXXXXX")
break;
dic.push_back(word);
}
while(true){
string word;
cin >> word;
if (word == "XXXXXX")
break;
multiset<char> chars;
string::iterator p;
for (p = word.begin( ); p != word.end( ); ++p)
chars.insert(*p);
set<string> result;
bool matched = false;
vector<string>::iterator dicp;
for (dicp = dic.begin( ); dicp != dic.end( ); ++dicp) {
if (word.length( ) == dicp->length( )) {
multiset<char> temp(chars);
string::iterator strp;
for (strp = dicp->begin( ); strp != dicp->end( ); ++strp) {
multiset<char>::iterator charp;
charp = temp.find(*strp);
if (charp == temp.end( ))
break;
temp.erase(charp);
}
if (temp.size( ) == 0) {
result.insert(*dicp);
matched = true;
}
}
}
if (!matched)
cout << "NOT A VALID WORD" << endl;
else {
set<string>::iterator p;
for (p = result.begin( ); p != result.end( ); ++p)
cout << *p << endl;
}
cout << "******" << endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -