Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. int countChar(const std::string &s) {
  2.  
  3. struct ischar {
  4. ischar(char x) : x(x) {}
  5. bool operator()(char y) const {
  6. if (!(isalpha(y)))
  7. return true;
  8. else
  9. return false;
  10. }
  11.  
  12. private:
  13. char x;
  14. };
  15.  
  16.  
  17. return std::count_if(s.begin(), s.end(), ischar(y));
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement