📄 justtry.m
字号:
function [chess,main,deputy,number]=justtry(i,n,chess,main,deputy,number);
if i==9
number=number+1
chess
else
for k=i:8
if main(i-chess(k)+n)==0&deputy(i+chess(k)-1)==0%此棋盘可继续放子(主,副对角线可放子)
t=chess(k);%交换
chess(k)=chess(i);
chess(i)=t;
main(i-chess(k)+n)=1;
deputy(i+chess(k)-1)=1;
[chess,main,deputy,number]=justtry(i+1,n,chess,main,deputy,number);%递归
t=chess(k);%回溯
chess(k)=chess(i);
chess(i)=t;
main(i-chess(k)+n)=0;
deputy(i+chess(k)-1)=0;
end
end
end
end%function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -