monito2207

Untitled

Oct 11th, 2022
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8.  
  9. int main() {
  10.     int Q, len, counter;
  11.     string str;
  12.     cin >> Q;
  13.     for (int i = 0; i < Q; i++){
  14.         counter = 0;
  15.         cin >> len >> str;
  16.         for (int j = 1; j < len + 1; j++){
  17.             if (str[j] == str[j-1]) { counter++; }
  18.         }
  19.         cout << counter << endl;
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment