请有2.0以上版本的朋友帮我求解下这个“八皇后”程序!
Title "Type your title here";constant N = 8; //皇后数目,可改动
IntParameter position(0:N-1);
Exclusive = True;
Minimum;
StartProgram;
var i, j, d: integer;
begin
d := 0;
for i := 0 to N-1 do begin
for j := i to N-1 do
if (abs(position-position) = abs(i-j))or(position = position) then
inc(d);
end;
FunctionResult := d;
end;
EndProgram; 目标函数是唯一的,但解不是唯一的。
目标函数值(最小): 8
position0: 4
position1: 6
position2: 1
position3: 5
position4: 2
position5: 0
position6: 3
position7: 7
页:
[1]