There are N students standing in a row and numbered 1 through N from left to right. You are given a string S with length N, where for each valid i, the i-th character of S is 'g' if the i-th student is a girl or 'b' if this student is a boy. Students standing next to each other in the row are friends.
#include<stdio.h> #include<string.h> int main() { char students[100001]; int t,j,count=0,length; scanf("%d",&t); while(t--){ count=0; scanf("%s",students); length=strlen(students); for(j=0;j<length;j++){ if((students[j]=='g'&&students[j+1]=='b')||(students[j]=='b'&&students[j+1]=='g')){ count++; j++;} else continue;} printf("%d\n",count);} return 0; }