fork(4) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool isNumber(string s) {
  6. if(s.size()==0) return false;
  7. for(int i=0;i<s.size();i++) {
  8. if((s[i]>='0' && s[i]<='9')==false) {
  9. return false;
  10. }
  11. }
  12. return true;
  13. }
  14.  
  15. int main()
  16. {
  17. if(isNumber("1243")) {
  18. cout << "It is a number!";
  19. }
  20. else {
  21. cout << "It is not a number!";
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
It is not a number!