| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <conio.h> int main(void) { char board[10][10]; int xpos = 1, ypos = 1; int k, i; // 보드를 초기화한다. for (int y = 0; y < 10; y++) for (int x = 0; x < 10; x++) board[y][x] = '.'; board[ypos][xpos] = '#'; board[9][9] = 'G'; board[5][5] = 'M'; board[6][7] = 'M'; printf("왼쪽이동:a, 오른쪽 이동:d 위쪽 이동:w, 아래쪽 이동:s\n"); // 사용자로부터 위치를 받아서 보드에 표시한다. while (1) { system("cls"); printf("왼쪽이동:a, 오른쪽 이동:d 위쪽 이동:w, 아래쪽 이동:s\n"); for (int y = 0; y < 10; y++) { for (int x = 0; x < 10; x++) printf("%c", board[y][x]); printf("\n"); } board[ypos][xpos] = '.'; int ch = _getch(); if (ch == 'a') xpos--; else if (ch == 's') ypos++; else if (ch == 'w') ypos--; else if (ch == 'd') xpos++; board[ypos][xpos] = '#'; } return 0; } | cs |
모범답안은 최소한의 것만 구현되어 있음
※ 추가구현 게시물의 암호는 내가 수업시간에 알려준 암호임


C프로그래밍(프로그래밍언어) 실습게시판