Advertisement
_takumi

num24

Nov 12th, 2020
675
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. #include <fstream>
  3. #include <algorithm>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream inFile("C:\\Users\\Максим\\Downloads\\24_demo.txt");
  10.     string s;
  11.     if (inFile)
  12.         getline(inFile, s);
  13.     s += s[s.size() - 1];
  14.     int max = 1;
  15.     int now = 1;
  16.     for (int i = 1; i < s.size(); i++) {
  17.         if (s[i] != s[i - 1]) {
  18.             now++;
  19.         }
  20.         else {
  21.             if (now > max) {
  22.                 max = now;
  23.             }
  24.             now = 1;
  25.         }
  26.     }
  27.     cout << max;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement