diff options
Diffstat (limited to '01_introductory_problems/repetitions_1069.cpp')
| -rw-r--r-- | 01_introductory_problems/repetitions_1069.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/01_introductory_problems/repetitions_1069.cpp b/01_introductory_problems/repetitions_1069.cpp new file mode 100644 index 0000000..790f315 --- /dev/null +++ b/01_introductory_problems/repetitions_1069.cpp | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #include <algorithm> | ||
| 2 | #include <iostream> | ||
| 3 | #include <string> | ||
| 4 | |||
| 5 | int main() { | ||
| 6 | char cur{'x'}; | ||
| 7 | int n{0}, m{0}; | ||
| 8 | std::string str; | ||
| 9 | std::cin >> str; | ||
| 10 | for (auto c : str) { | ||
| 11 | if (c == cur) { | ||
| 12 | n++; | ||
| 13 | } else { | ||
| 14 | m = std::max(m, n); | ||
| 15 | n = 1; | ||
| 16 | cur = c; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | std::cout << std::max(m, n) << std::endl; | ||
| 20 | } | ||
