diff options
Diffstat (limited to 'challenge-282/deadmarshal/cpp/ch-2.cpp')
| -rw-r--r-- | challenge-282/deadmarshal/cpp/ch-2.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-282/deadmarshal/cpp/ch-2.cpp b/challenge-282/deadmarshal/cpp/ch-2.cpp new file mode 100644 index 0000000000..286b8d2dfc --- /dev/null +++ b/challenge-282/deadmarshal/cpp/ch-2.cpp @@ -0,0 +1,20 @@ +#include<iostream> +#include<string> +#include<cctype> + +std::size_t changing_keys(const std::string &str) +{ + std::size_t count{}; + for(std::size_t i = 1; i < str.size(); ++i) + if(tolower(str[i]) != tolower(str[i-1])) count++; + return count; +} + +int main() +{ + std::cout << changing_keys("pPeERrLl") << '\n' + << changing_keys("rRr") << '\n' + << changing_keys("GoO") << '\n'; + return 0; +} + |
