fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. bool ok(const std::string &input) {
  5. return std::find_if_not(
  6. input.begin(), //from beginning
  7. input.end(), //to end
  8. isalpha //check for non-alpha characters
  9. ) == input.end();
  10. }
  11.  
  12. int main() {
  13. std::cout <<
  14. ok("abc") << '\n' <<
  15. ok("123") << '\n' <<
  16. ok("1.4") << '\n' <<
  17. ok("abc8def") << '\n' <<
  18. ok("My name is Chris.");
  19. }
Success #stdin #stdout 0s 3020KB
stdin
Standard input is empty
stdout
1
0
0
0
0