본문내용
public class maze
{
public int m,n; //배열의 크기
public int [][] maze; //미로를 위한 배열
public int [][] mark; //경로를 위한 배열
public int [][] stack; //이동방향과 위치를 저장하는 스택
public static int [][] move = { {-1,0}, {0,1}, {1,0}, {0,-1}}; //이동할 방향을 위한 배열. 북, 동, 남, 서
public static int top = -1;
public int i, j; //미로에서 현재 위치
public int next_i, next_j; //미로에서 이동할 위치
public int dir; //미로에서 이동할 방향
//미로 프로그램의 초기화
public maze(int m, int n, int[][] maze)
{
this.m = m; //미로의 행크기
this.n = n; //미로의 열크기
this.maze = maze; //미로를 배열에 저장
mark = new int [m+2][n+2]; //경로를 위한 배열 생성.
//mark 배열 초기화
for(int i=0;i
{
for(int j=0;j
{
mark[i][j] = 0;
}//end inner for
}//end outer for
stack = new int[(m+2)*(n+2)][3]; //최대경우의 수만큼 위치와 이동방향을 저장할 스택 생성
}
//미로 찾기
void path()
{
i =1 ; j = 1; dir = 1; //현재위치와 이동방향 초기화
mark[i][j] = 1; //현재위치 저장
System.out.println("---push---");
for(int a=0; a
{
for(int b=0; b
{
if(maze[a][b]==1)
System.out.print("#");
else
{ if(a==i && b==j) System.out.print("o");
else
System.out.print(" ");
}
}
System.out.println();
}
System.out.println("---push---");
push(i, j, dir); //미로 입구에서 동쪽으로 이동하게 초기화
//경로 찾기 시작
while(!(isEmpty()))
{
pop(); //길을 잘못 들어갔을 경우, 뒤로 되돌아옴.
while(dir <= 3) //길을 찾아감
{
next_i = i + move[dir][0]; //다음으로 이동할 경로(행)
next_j = j + move[dir][1];
{
public int m,n; //배열의 크기
public int [][] maze; //미로를 위한 배열
public int [][] mark; //경로를 위한 배열
public int [][] stack; //이동방향과 위치를 저장하는 스택
public static int [][] move = { {-1,0}, {0,1}, {1,0}, {0,-1}}; //이동할 방향을 위한 배열. 북, 동, 남, 서
public static int top = -1;
public int i, j; //미로에서 현재 위치
public int next_i, next_j; //미로에서 이동할 위치
public int dir; //미로에서 이동할 방향
//미로 프로그램의 초기화
public maze(int m, int n, int[][] maze)
{
this.m = m; //미로의 행크기
this.n = n; //미로의 열크기
this.maze = maze; //미로를 배열에 저장
mark = new int [m+2][n+2]; //경로를 위한 배열 생성.
//mark 배열 초기화
for(int i=0;i
for(int j=0;j
mark[i][j] = 0;
}//end inner for
}//end outer for
stack = new int[(m+2)*(n+2)][3]; //최대경우의 수만큼 위치와 이동방향을 저장할 스택 생성
}
//미로 찾기
void path()
{
i =1 ; j = 1; dir = 1; //현재위치와 이동방향 초기화
mark[i][j] = 1; //현재위치 저장
System.out.println("---push---");
for(int a=0; a
for(int b=0; b
if(maze[a][b]==1)
System.out.print("#");
else
{ if(a==i && b==j) System.out.print("o");
else
System.out.print(" ");
}
}
System.out.println();
}
System.out.println("---push---");
push(i, j, dir); //미로 입구에서 동쪽으로 이동하게 초기화
//경로 찾기 시작
while(!(isEmpty()))
{
pop(); //길을 잘못 들어갔을 경우, 뒤로 되돌아옴.
while(dir <= 3) //길을 찾아감
{
next_i = i + move[dir][0]; //다음으로 이동할 경로(행)
next_j = j + move[dir][1];
추천자료
- [자료구조] max heap
- [자료구조] BFS&DFS&BST
- [자료구조] post&prefix
- 자료구조 하노이타워(자바)
- [자료구조, Algorithm] 외부정렬(External Sort) PPT version
- [자료구조]다익스트라 최단 경로 알고리즘
- [자료구조]포인터 배열 삽입 정렬
- [자료구조] 정렬되지 않는 배열 (우선 순위 큐)
- 자료구조 하노이탑 소스
- SK텔레콤 자본구조발표자료
- [자료구조] 피보나치수열 - int 데이타 사이즈를 넘어가는 결과값 계산 프로그램
- C언어 자료구조 Binary Search Tree (이진 탐색 트리)
- C언어 자료구조 HashTable 해시테이블
- [자료구조] Linked List를 이용한 예약프로그램 - 버스예약 프로그램을 Linked_list로 구현한다
소개글