A: Title
Type a few words, all the following conditions to find words: the word can not be obtained by rearranging the letters in the input text to another word. When it is judged whether the condition, case insensitive, but in case the output should remain in the input, arranged for lexicographically
The input word will be "normalized", is about the word each letter into a lower case and press lexicographical rearrangement word, use a dictionary to a standardized statistical word appears how many times, when only the output of the output in standard dictionaries one of those words can occur.
(A) Sample Input
ladder came tape soon leader acme RIDE lone Dreis peat
ScAlE orb eye Rides dealer NotE derail LaCeS drIed
noel dire Disk mace Rob dries
#
(B) Sample Output
Disk
NotE
derail
drIed
eye
ladder
soon
Two: code implementation
#define _CRT_SECURE_NO_WARNINGS #define _SCL_SECURE_NO_WARNINGS #include <iostream> #include <map> #include <string> #include <sstream> #include <algorithm> using namespace std; map<string, string> source; map<string, bool> result; int main() { freopen("data5_4.in", "r", stdin); freopen("data5_4.out", "w", stdout); char low_str[21]; string str; while (true) { cin >> str; if (str == "#") break; for (int i = 0; i < str.length()+1; i++) low_str[i] = tolower(str[i]); //转小写 Sort (low_str, low_str + str.length ()); // string sort source.insert (pair <String, String> (STR, String (low_str))); // the source string, the string sort - -> inserted into the map Auto PI = result.find (string (low_str)); // string to find out whether the sort result map iF(PI ==result.end ()) result.insert (pair <string, BOOL> (string (low_str), true) ); // If this is the first time, is set to true the else PI-> = sECOND to false ; // if multiple occurrences, is set to false } //traverse process for(Map <String,String> :: = source.begin ITER Iterator (); ITER source.end = ();! ITER ++) { IT Auto = result.find (iter-> SECOND); IF ((IT *) .second) // find all appear only once in the mapping result string COUT << iter-> First << endl; / / string output source } The freopen ("CON","R & lt", stdin); The freopen ("CON","W", stdout); return 0; }