fork(3) download
  1. #include <iostream>
  2. #include <vector>
  3. #include<string>
  4. #include<algorithm>
  5.  
  6. using namespace std;
  7.  
  8. struct Compare {
  9. std::string str;
  10. Compare(const std::string& x) : str(x) {
  11. std::sort(str.begin(),str.end()); std::transform(str.begin(),
  12. str.end(),str.begin(), ::toupper);}
  13.  
  14. bool operator ()(const std::string& t)
  15. {
  16. std::string s= t;
  17. std::transform(s.begin(), s.end(),s.begin(), ::toupper);
  18. std::sort(s.begin(),s.end());
  19.  
  20. return s == str;
  21. }
  22. };
  23.  
  24.  
  25.  
  26.  
  27. int main(int argc, char *argv[]) {
  28.  
  29. std::vector<std::string> words {"Vile","Veil", "Live"};
  30.  
  31. int count = std::count_if(words.begin(), words.end(), Compare("Evil"));
  32.  
  33. cout << count << endl;
  34. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
3