Algorithm

하얀 칸 (백준 알고리즘 1100번)

OOOooOOoo·2019년 5월 24일·조회 3,068

1. 문제

https://www.acmicpc.net/problem/1100


2. 코드

	public static void main(String[] args) {
		List<String> input = new ArrayList<String>();

		input.add(".F.F...F");
		input.add("F...F.F.");
		input.add("...F.F.F");
		input.add("F.F...F.");
		input.add(".F...F..");
		input.add("F...F.F.");
		input.add(".F.F.F.F");
		input.add("..FF..F.");

		int count = 0;

		for (int i = 0; i < input.size(); i++) {
			String str = input.get(i);

			for (int y = 0; y < str.length(); y++) {
				char c = str.charAt(y);
				if (c == 'F') {
					if ((i % 2 == 1 && y % 2 == 1) || (i % 2 == 0 && y % 2 == 0)) {
						count++;
					}
				}
			}
		}

		System.out.println("count=" + count);
	}

댓글 0

로그인 후 댓글을 남길 수 있습니다.

아직 댓글이 없습니다.