백준 1100 java

magicdrill·2024년 2월 23일

백준 문제풀이

목록 보기
26/673

백준 1100 java

import java.util.Scanner;

public class bj1100 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i, j, total = 0;
        String temp = "";

        for(i = 0; i < 8; i++)
        {
            temp = scanner.next();
            for(j = 0; j < 8; j++)
            {
                if(i % 2 == 0)//짝수 줄
                {
                    if(j % 2 == 0 && temp.charAt(j) == 'F')//짝수 번
                    {
                        total++;
                    }
                }
                else//홀수 줄
                {
                    if (j % 2 == 1 && temp.charAt(j) == 'F')//홀수 번
                    {
                        total++;
                    }
                }
            }
        }
        System.out.println(total);

        scanner.close();
    }
}

0개의 댓글