【问题描述】
有一个 10 x 10 的迷宫,起点是‘S’,终点是‘E’,墙是‘#’,道路是空格。一个机器人从起点走到终点。当机器人走到一个通道块,前面已经没有路可走时,它会转向到当前面向的右手方向继续走。如果机器人能够过,则留下足迹‘*’,如果走不通,则留下标记‘!’。
下面给出算法,请你模拟机器人的走法输出最终的状态。
【输入形式】
一个 10 x 10 的二维字符数组。
【输出形式】
机器人走过的路径状态。
【样例输入】
##########
#S # # #
# # # #
# ## #
# ### #
# # #
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
char a[10][10];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct Stack
{
int x[1000];
int y[1000];
int top;
};
void Init(Stack *&s)
{
s=(Stack*)malloc(sizeof(Stack));
s->top=-1;
}
void Push(Stack *s,int x,int y)
{
if(s->top==999)
{
cout<<"栈已满,无法进行相应的操作!";
return;
}
s->top++;
s->x[s->top