Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string str;
- cout << "Enter string:\n";
- getline (cin, str);
- int countOfNums = 0;
- for (int i = 0; i < str.length(); i++) {
- if (((int)str[i] >= (int)'0') && ((int)str[i] <= (int)'9')) {
- countOfNums++;
- }
- }
- cout << countOfNums << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement