#include <iostream> #include <string> using namespace std; int main() { string stones; int n,count; while(cin>>n>>stones) { count=0; for(int i=0; i<stones.size()-1; ++i) if(stones[i]==stones[i+1]) ++count; cout<<count<<endl; } return 0; }
2023-01-21 16:32:29
#include <iostream> #include <string> using namespace std; int main() { string stones; int n,count; while(cin>>n>>stones) { count=0; for(int i=0; i<stones.size()-1; ++i) if(stones[i]==stones[i+1]) ++count; cout<<count<<endl; } return 0; }