#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;
}