반응형
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int testCase=1; testCase<=T; testCase++) {
String st = sc.next();
int count = 0;
for(int i=0; i<st.length(); i++) {
if(i==0) {
if(st.charAt(i) == '1') count++;
} else {
if(st.charAt(i) != st.charAt(i-1)) count++;
}
}
System.out.println("#" + testCase + " " + count);
}
}
}
반응형
'알고리즘 > 문제풀이' 카테고리의 다른 글
[SWEA] 1210. [S/W 문제해결 기본] 2일차 - Ladder1 (0) | 2020.01.25 |
---|---|
[SWEA] 5215.햄버거 다이어트 (0) | 2020.01.25 |
[7576] 토마토 (0) | 2019.12.13 |
[프로그래머스] 네트워크 (0) | 2019.12.13 |
[10974] 모든 순열 (0) | 2019.10.13 |