aboutsummaryrefslogtreecommitdiff
path: root/challenge-282/deadmarshal/cpp/ch-2.cpp
blob: 286b8d2dfc44c0ff540d2f75859b5a9bc7f567bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}