Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. int main () {
  7.     string userInput;
  8.     float hasDigit = 1; //if has digit > 0 then the string has a digit
  9.     int i;
  10.    
  11.     getline(cin, userInput);
  12.    
  13.     i = userInput.length();
  14.    
  15.     /*do {
  16.         hasDigit = hasDigit * isdigit(userInput.at(i));
  17.         i--;
  18.     } while(i > 0);*/
  19.    
  20.     for (0; i < 0; --i) {
  21.         hasDigit = hasDigit * isdigit(userInput.at(i));
  22.     }
  23.    
  24.     if (hasDigit != 0) {
  25.         cout << "yes" << endl;
  26.     }
  27.     else if (hasDigit == 0) {
  28.         cout << "no" << endl;
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement