Advertisement
juanjo12x

UVA_156_Anagrams

Aug 14th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <numeric>
  5. #include <sstream>
  6. #include <fstream>
  7. #include <cassert>
  8. #include <climits>
  9. #include <cstdlib>
  10. #include <cstring>
  11. #include <string>
  12. #include <cstdio>
  13. #include <vector>
  14. #include <cmath>
  15. #include <queue>
  16. #include <deque>
  17. #include <stack>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. using namespace std;
  22.  
  23.  
  24. int main(){
  25.     map <string, pair<string,int> > words;
  26.     vector<string> result;
  27.     string word,wordSorted;cin>>word;
  28.     while(word != "#"){
  29.         wordSorted=word;
  30.         transform(wordSorted.begin(), wordSorted.end(),wordSorted.begin(),::toupper);
  31.         sort(wordSorted.begin(),wordSorted.end());
  32.         words[wordSorted].first=word;
  33.         words[wordSorted].second++;
  34.         cin>>word;
  35.     }
  36.     map<string, pair<string,int> >::const_iterator itr;
  37.     for(itr = words.begin(); itr != words.end(); ++itr){
  38.             if((*itr).second.second == 1)
  39.                 result.push_back((*itr).second.first);
  40.     }
  41.     sort(result.begin(),result.end());
  42.     int total = result.size();
  43.     for (int i = 0; i < total; ++i)
  44.     {
  45.         cout<<result[i]<<endl;
  46.     }
  47.  return 0;  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement