diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2024-08-13 10:14:31 +0330 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2024-08-13 10:14:31 +0330 |
| commit | 1ed5f4218d591921274087ec0feeb402e91201d4 (patch) | |
| tree | 01b919f2703d4ff37c21550096010da98f5ab413 /challenge-282/deadmarshal/cpp/ch-2.cpp | |
| parent | 6bc37eb88f4850e1f6fc02a038163fb382f296dc (diff) | |
| download | perlweeklychallenge-club-1ed5f4218d591921274087ec0feeb402e91201d4.tar.gz perlweeklychallenge-club-1ed5f4218d591921274087ec0feeb402e91201d4.tar.bz2 perlweeklychallenge-club-1ed5f4218d591921274087ec0feeb402e91201d4.zip | |
TWC282
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; +} + |
