~cpp 
#include <stdio.h>
#include <time.h>
#include <conio.h>
#define MAP_X 5
#define MAP_Y 5
typedef struct ztype {
	int row;
	int col;
}ztype;
int move(ztype );
void prtpoint();
int map[MAP_X][MAP_Y]={
		{0,1,0,0,0},
		{1,0,0,0,1},
		{0,1,1,0,0},
		{1,1,0,1,1},
		{1,1,1,0,0}
};
/*
int map[MAP_X][MAP_Y]={
	{0,1,0,0,0,1,1,0,0,0,1,1,1,1,1},
	{1,0,0,0,1,1,0,1,1,1,0,0,1,1,1},
	{0,1,1,0,0,0,0,1,1,1,1,0,0,1,1},
	{1,1,0,1,1,1,1,0,1,1,0,1,1,0,0},
	{1,1,0,1,0,0,1,0,1,1,1,1,1,1,1},
	{0,0,1,1,0,1,1,1,0,1,0,0,1,0,1}, 
	{0,1,1,1,1,0,0,1,1,1,1,1,1,1,1}, 
	{0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, 
	{1,1,0,0,0,1,1,0,1,1,0,0,0,0,0}, 
	{0,0,1,1,1,1,1,0,0,0,1,1,1,1,0}, 
	{0,1,0,0,1,1,1,1,1,0,1,1,1,1,0}
};
*/
ztype p,go; //ヌ・タァト。
int main()
{
	int x,y,run=0;
	srand(time(NULL));
	//テハア箍ェ;
	p.col =0;
	p.row =0;
	
	while(1) {
		system("cls");
		x = (rand()%3)-1;
		y = (rand()%3)-1;
		if(x==0 && y==0) continue;
		go.row = p.row + y;
		go.col = p.col + x;
		move(go);
		run++;
		printf("%d ケー スヌヌ狠゚\n",run);
		prtpoint();
		
		//クカチキ トュソ。 オオツ゚タサ ー豼・
		if(p.col==MAP_X-1 && p.row ==MAP_Y-1) break;
	} 
	
	printf("%dケクソ。 ナサテ・シコー!\n",run);
	return 0;
}
int move(ztype to)
{
	//ケ霑ュタヌ ケ・ァクヲ ケセ鋧ッ カァ 、キ、オ、キ;;
	if(to.col<0 || to.col > MAP_X-1 || to.row<0 || to.row > MAP_Y-1)
	{
		return 1;
	}
	
	//クハソ。シュ コョ(1)タマカァ
	if(map[to.row][to.col]==1){
		return 1;
	}
	p = to;
	return 0;
}
void prtpoint()
{
	int i,j;
	for(i=0;i<MAP_Y;i++)
	{
		for(j=0;j<MAP_X;j++)
		{
			if(p.col==j &&p.row ==i) 
				printf("X ");
			else 
				printf("%d ",map[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	getch();
	
}