harmirton.m
来自「哈密顿马步图回路问题」· M 代码 · 共 47 行
M
47 行
function [ chain ] = harmirton( m ,n )%HARMIRTON Summary of this function goes here% Detailed explanation goes herechain=[];mask=zeros(m,n);queueMask=0;queueStructure{1}.tmpNode=[];currentQueuePos=1;IsLoop=0;while(1) if queueMask==0 tmpNode=findldNode(mask); if isempty(tmpNode) if size(chain,1)>1 & currentQueuePos>1 popQueue; else chain=[]; break; end end end queueMask=0; if (size(tmpNode,2)==3) [chain,mask,IsLoop]=updateChain(chain,mask,tmpNode); else pushQueue; [chain,mask,IsLoop]=updateChain(chain,mask,tmpNode(1,1:3)); end if (IsLoop==1) IsLoop=0; if (currentQueuePos>1) popQueue; queueMask=1; else chain=[]; break; end else if IsLoop==2 break; end end end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?