function [total,maze]=search(i,j,maze,total);
fx(1:4)=[1,0,-1,0];
fy(1:4)=[0,1,0,-1];
for k=1:4
newi=i+fx(k);
newj=j+fy(k);
if (newi<=8)&(newj<=8)&(newi>=1)&(newj>=1)&maze(newi,newj)==0
maze(newi,newj)=2;%此点已走
if newi==8&newj==8
total=total+1
maze
else
[total,maze]=search(newi,newj,maze,total);
end%if i+fx(k)==8&j+fy(y)==8
maze(newi,newj)=0;%回溯
end%if (newi<=8)&(newj<=8)&(newi>=1)&(newj>=1)&maze(newi,newj)==0
end%for k=1:4
end
密宫所有路_回溯_matlab
版权申诉
153 浏览量
2022-04-08
23:10:11
上传
评论
收藏 1KB ZIP 举报
阿里matlab建模师
- 粉丝: 3331
- 资源: 2784