Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream inFile("C:\\Users\\Максим\\Downloads\\zadanie24_1.txt");
- string s;
- if (inFile)
- getline(inFile, s);
- int max = 1;
- int now = 1;
- for (int i = 1; i < s.size(); i++) {
- if (s[i] == 'B' && s[i - 1] == 'B') {
- now++;
- }
- else {
- if (now > max) {
- max = now;
- }
- now = 1;
- }
- }
- cout << max;
- }
- /*Текстовый файл состоит не более чем из 106 символов A, B и C. Определите максимальное количество идущих подряд символов B.
- Для выполнения этого задания следует написать программу. Ниже приведён файл, который необходимо обработать с помощью данного алгоритма.*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement