SWEA 1289元のメモリを復元


問題が読めさえすれば、実施は難しくない.
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);
			
		}
	}
}