숭실대학교 3번째 과제, 스택을 이용한 미로찾기 C++구현
- 최초 등록일
- 2010.05.19
- 최종 저작일
- 2010.05
- 텍스트
- 가격 2,000원
소개글
숭실대학교 3번째 과제입니다.
스택을 이용하여 마지막에 경로를 출력해주는 문제입니다.
push, pop, isEmpty등 명세에 있는대로 코드를 구현하였습니다.
#include
#include "stdlib.h"
#include "time.h"
using namespace std;
class Location{ //location 클레스
public:
int isExit;//=false;
int left,up,right,down;
void set(int a,int b,int c,int d); //위치 함수 정의
};
void Location::set(int a,int b,int c,int d){ //set 멤버 함수 클레스 외부에 정의.
isExit=0;
left=a;
up=b;
right=c;
down=d;
}
class Finding{
public:
int x;
int y;
bool select[4];
int choice;
};
class MazeStack{
public:
int top;
Finding find[100];
void MazeStack::push(int x, int y, Finding c);
Finding pop();
int IsEmpty(int top);
MazeStack::MazeStack();
};
MazeStack::MazeStack(){
top=-1;
}
void MazeStack::push(int x, int y, Finding c){
int i;
top=top+1;
if(top==99){
cout<<"꽉 참";
return;
}
else{
find[top].x=x;
find[top].y=y;
.....................
....................
...............
void Maze::Move(int x, int y){
robot.x = x;
robot.y = y;
current.x = x;
current.y= y;
int i=0;
for(i=0; i<4; i++)
current.select[i]=false;
....
...
컴파일 실행환경
Visual c++6.0
참고 자료
없음