diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
| commit | 96254947699986c59f0dc63d69fd4b76bd3ed43e (patch) | |
| tree | 6c4dca945d7f7427c48be234d827fe4d33be02c5 /01_introductory_problems/repetitions_1069.cpp | |
| download | cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.tar.gz cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.zip | |
Initial commit
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 | } | ||
