Advertisement
cska1312

Alphabetical changes

Feb 19th, 2023 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int findStrCount(string str)
  5. {
  6.   int count = 0;
  7.   int n = str.size();
  8.  
  9.   for(int i = 0; i < n - 1; i++)
  10.   {    
  11.       if(str[i] < str[i+1]){
  12.               i++;
  13.     if(str[i] > str[i+1])
  14.       count++;
  15.         if(str[i] < str[i+1])
  16.       count++;
  17.       }
  18.          
  19.         }
  20.   return count;
  21. }
  22.  
  23. int main()
  24. {
  25.     string str;
  26.     cin >> str;
  27.  
  28.     cout << findStrCount(str) << endl;
  29.  
  30.     return 0;
  31. }
  32. //a  b  c  z - a - z - b - 3 пъти
  33. //0  1  2  3   4   5   6
  34.  
  35. //a  b  d  g  z  z - m  f  a - b  c - 2 пъти
  36. //0  1  2  3  4  5   6  7  8   9  10
  37.  
  38. //a  b  z - b - c  z  z - a - 3 пъти
  39. //1  2  3   4   5  6  7   8
  40.  
  41. //a  b  e  z - m  a - z - a - 3 пъти
  42. //1  2  3  4   5  6   7   8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement