문제를 읽고 이해할 수 있으면 구현은 어렵지 않다.
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
char[] c = sc.next().toCharArray();
int count = 0;
if(c[0] == 49
) count++;
for(int i = 0; i < c.length - 1; i++) {
if(c[i] != c[i+1]) {
count++;
}
}
System.out.printf("#%d %d\n", test_case, count);
}
}
}