⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 justtry.m

📁 数学建模各种模型的MATLAB源码,包括灰色模型、回归模型及回归检验、最小生成树、最短路径等
💻 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 + -