1100번 문제[링크]

문제에서 집중해야 할 내용/이 문제를 당락짓는 요인
1. 하얀 칸과 검은 칸을 어떻게 구분 지을 수 있는가?
2. 많은 char형 변수들을 어떻게 받을 수 있는가?
문제의 해결책
1. 행렬로 생각하여 행이 홀수일 때 열이 짝수 / 행이 짝수일 때 열이 홀수인 경우에 하얀칸에 해당된다.
2. char형은 gets함수를 이용하여 입력받을 수 있다. 단, 언어 설정시 C로 설정해주어야 한다.(C++에 존재하지 못한다.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Baekjoon Problem: https://www.acmicpc.net/problem/1100 | |
#include <stdio.h> | |
int main() { | |
char arr[8][8]; | |
int i, j, k, l, cnt=0; | |
for(i = 0; i < 8; i++) | |
gets(arr[i]); | |
for(i=0; i<8; i+=2) | |
for(j=0; j<8; j+=2) | |
if(arr[i][j] == 'F') | |
cnt++; | |
for(k=1; k<8; k+=2) | |
for(l = 1; l<8; l+=2) | |
if(arr[k][l] == 'F') | |
cnt++; | |
printf("%d\n", cnt); | |
return 0; | |
} | |
'Robotics & Perception > Basic' 카테고리의 다른 글
[Modern Robotics] Contents (0) | 2022.04.02 |
---|---|
[Graphics] Obj (0) | 2022.02.02 |
[기초] 1. Introduction (0) | 2022.01.05 |
[기초] TAMP: Task and Motion Planning 소개 (0) | 2022.01.02 |
[기초] ROS 기본 개념 정리 (0) | 2021.01.22 |