백준1100

hong030·2023년 2월 4일
0
post-thumbnail
  • solved.ac 기준 브론즈 2단계 문제

풀이)
입력을 2차원 배열에 저장하는 방법을 생각해야 한다.
2차원 배열을 먼저 선언하고 >>
String str[] = br.ReadLine().split();으로 1차원 배열을 만든다음,
2중 for문을 통해 array[i][j] 에 str[j]값을 넣는다.

내 코드)

import java.io.*;

public class Main {
	public static void main(String[]args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String arr[][] = new String[8][8];
		int count = 0;
		
		for(int i = 0;i<8;i++) {
			String[]str = bf.readLine().split("");
			for(int j = 0; j<8;j++) {
				arr[i][j] = str[j];
				if((i+j) % 2 == 0 && arr[i][j].equals("F"))
					count ++ ;					
			}
		}
		System.out.println(count);

	}
}

profile
자바 주력, 프론트 공부 중인 초보 개발자. / https://github.com/hongjaewonP

0개의 댓글