%let c=0;
%qIter(PartialSolution=,List=1 2 3 4 5 6 7 8,Level=1,CounterName=c)[/code:24ah0g9z]作者: shiyiming 时间: 2011-7-26 18:28 标题: Re: SAS解决八皇后问题 我以前写的解法。哈哈
[code:248c7omk]%macro test(level);
do i=1 to &level-1 ;/*test eligibility*/
if x(&level)=x(i) then do;failed=1;leave;end;
if x(&level)-x(i)=&level-i then do;failed=1;leave;end;
if x(i)-x(&level)=&level-i then do;failed=1;leave;end;
end;
if failed then do;failed=0;continue;end;
%mend;
%macro inner(level);
do x&level=1 to 8;
%test(&level)
%mend;