Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int findStrCount(string str)
- {
- int count = 0;
- int n = str.size();
- for (int i = 0; i < n - 1; i++)
- {
- if (str[i] + 1 == str[i + 1])
- {
- count++;
- while (str[i] + 1 == str[i + 1])
- {
- i++;
- }
- }
- }
- return count;
- }
- int main()
- {
- string str;
- cin >> str;
- cout << findStrCount(str) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement