fork download
  1. #include <string>
  2. #include <algorithm>
  3. #include <cctype>
  4. #include <iostream>
  5.  
  6. //...
  7. bool isValidZipCode(const std::string& s)
  8. {
  9. return s.size() == 5 && std::all_of(s.begin(), s.end(), ::isdigit);
  10. }
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. cout << isValidZipCode("01234") << "\n";
  17. cout << isValidZipCode("01a34") << "\n";
  18. cout << isValidZipCode("9134") << "\n";
  19. cout << isValidZipCode("91344") << "\n";
  20. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1
0
0
1