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] > str[i+1]){
- count++;
- i++;
- if(str[i] < str[i+1])
- count++;
- }
- }
- return count;
- }
- int main()
- {
- string str;
- cin >> str;
- cout << findStrCount(str) << endl;
- return 0;
- }
- //a b c z - a - z - b - 3 пъти
- //0 1 2 3 4 5 6
- //a b d g z z - m f a - b c - 2 пъти
- //0 1 2 3 4 5 6 7 8 9 10
- //a b z - b - c z z - a - 3 пъти
- //1 2 3 4 5 6 7 8
- //a b e z - m a - z - a - 3 пъти
- //1 2 3 4 5 6 7 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement