코드포스 266A (codeforces 266A)

코드포스 266A (codeforces 266A) 문제 풀이 및 코드 (description and code)

목차

Problem - 266A - Codeforces

코드

import java.io.*;

public class CF266A {
    static int n, count = 0, cur;
    static String in;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        n = Integer.parseInt(br.readLine());
        in = br.readLine();cur = in.charAt(0);
        for (int i = 1; i < n; i++) {
            count += (cur == in.charAt(i)) ? 1 : 0;
            cur = in.charAt(i);
        }
        bw.write(count + "\n");
        bw.flush();bw.close();
    }
}

설명

Copied to clipboard