Title Description:
Enter some words to find all the words that meet the following criteria: The word cannot be re-ranked by the letter to get another word in the input text. Letters are not case-sensitive when determining whether a condition is met, but the case in the input should be preserved in the output, arranged in dictionary order (all uppercase letters are preceded by all lowercase letters).
#include <iostream>#include<vector>#include<string>#include<algorithm>#include<cctype>#include<map>using namespaceStd;map<string,int>Cnt;vector<string>words;//"Standardization" of wordsstringRepr (Const string&s) { stringcs=s; for(intI=0; I<cs.length (); i++) {Cs[i]=ToLower (Cs[i]); } sort (Cs.begin (), Cs.end ()); returnCS;}intMain () {strings; while(cin>>s) {if(s[0]=='#') Break; Words.push_back (s); stringcs=repr (s); if(!cnt.count (CS)) cnt[cs]=0; CNT[CS]++; } Vector<string>ans; for(intI=0; I<words.size (); i++) { if(Cnt[repr (words[i])]==1) Ans.push_back (Words[i]);//If you don't think of "normalization", you don't get the effect of map} sort (Ans.begin (), Ans.end ()); for(intI=0; I<ans.size (); i++) {cout<<ans[i]<<Endl; } return 0;}
Count different words (Map app)