fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int is_number(const std::string& s)
  8. {
  9. for(int count = 0; s.c_str()[count];)
  10. {
  11. if (isdigit(s[count]))
  12. ++count;
  13. else
  14. return 0;
  15. }
  16. return 1;
  17. }
  18.  
  19. int main(int argc, const char * argv[])
  20. {
  21. cout << is_number("sdvjv sdgv") << endl;
  22. cout << is_number("6732587523") << endl;
  23. cout << is_number("Привет! 67569") << endl;
  24. cout << is_number("237652347 вот...") << endl;
  25. }
  26.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0
1
0
0