Advertisement
MadCortez

Untitled

Jan 5th, 2021
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "Russian");
  8.     cout << "Введите строку: " << endl;
  9.     string s;
  10.     cin >> s;
  11.     s = s + " ";
  12.     int max = 1;
  13.     int maxAnswer = 0;
  14.     for (int i = 1; i < s.size(); i++)
  15.         if (s[i] == s[i - 1])
  16.             max++;
  17.         else {
  18.             if (max > maxAnswer)
  19.                 maxAnswer = max;
  20.             max = 1;
  21.         }
  22.     cout << maxAnswer;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement