fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10. vector<string> words = {"Helo", "Alska", "Dad", "Peace"};
  11. std::string s1 = "eiopqrtuwy", s2 = "adfghjkls", s3 = "bcmnvxz";
  12.  
  13. vector<string> res;
  14. for(auto temp : words)
  15. {
  16. string ww = temp;
  17.  
  18. //sort(w.begin(), w.end());
  19.  
  20. transform(ww.begin(), ww.end(), ww.begin(), ::tolower);
  21.  
  22. std::set<char> w (ww.begin(), ww.end());
  23.  
  24. //cout << temp << " ";
  25.  
  26. if ( ( std::includes( s1.begin(), s1.end(), w.begin(), w.end() ) )
  27. || ( std::includes( s2.begin(), s2.end(), w.begin(), w.end() ) )
  28. || ( std::includes( s3.begin(), s3.end(), w.begin(), w.end() ) ) )
  29. res.push_back(temp);
  30. //else cout << temp << " ";
  31. }
  32.  
  33. for(auto w : res)
  34. cout << w << " ";
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 16056KB
stdin
Standard input is empty
stdout
Alska Dad