'로봇 청소기' 태그의 글 목록
본문 바로가기
728x90
반응형

로봇 청소기3

22-04-11-14503-로봇청소기 01.청소방향 확인하는 소스 int idx = 0; int y = robot.y, x = robot.x; int dir = robot.dir; for (idx = 0; idx < 4; idx++) { dir--; if (dir == -1) dir = 3; pos next; next.y = y + dy[dir]; next.x = x + dx[dir]; if (board[next.y][next.x] == 0) { // 청소 공간이 있는경우 회전후 전진 robot.y = next.y; robot.x = next.x; robot.dir = dir; break; } } 02.청소구간이 없는 경우 후진 또는 종료 if (idx == 4)// 청소구간이 없는 경우 후진 또는 종료 { pos prev; prev.y =.. 2022. 4. 11.
2021년09월04일_14503-로봇청소기 소스코드 #include #include #include #define N_MAX_SIZE 51 #define M_MAX_SIZE 51 int N, M; int board[N_MAX_SIZE][M_MAX_SIZE]; int dy[] = { -1,0,1,0 }; int dx[] = { 0,1,0,-1 }; struct posData { int y, x, dir; }robot; void init(); void init_test(); void cleanRoom(); int main(void) { int testCase = 1; for (int tc = 1; tc 2021. 9. 4.
14503 로봇 청소기 https://www.acmicpc.net/problem/14503 14503번: 로봇 청소기 로봇 청소기가 주어졌을 때, 청소하는 영역의 개수를 구하는 프로그램을 작성하시오. 로봇 청소기가 있는 장소는 N×M 크기의 직사각형으로 나타낼 수 있으며, 1×1크기의 정사각형 칸으로 나누어 www.acmicpc.net #include #include #include using namespace std; #define MAP_SIZE 51 int N, M;//행 열 int map[MAP_SIZE][MAP_SIZE]; int dy[] = { -1,0,1,0 }; int dx[] = { 0,1,0,-1 }; int y, x, dir; bool safe(int y, int x) { return 0 2020. 7. 22.
728x90
반응형