Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program TamQuanHau;
- Uses Crt;
- Type mang = array[1..8] of Integer;
- Var
- x: mang;
- a: array[1..8] of Boolean;
- b: array[2..16] of Boolean;
- c: array[-7..7] of Boolean;
- i,j,k: Integer;
- antoan: Boolean;
- procedure print(m: mang);
- var k: Integer;
- begin
- for k:=1 to 8 do write(m[k]);
- writeln;
- end;
- procedure try;
- begin
- repeat
- repeat
- i:=i+1;
- antoan:=a[i] and b[i+j] and c[i-j];
- until antoan or (i=8);
- if antoan then
- begin
- x[j]:=i;
- a[i]:=false; b[i+j]:=false; c[i-j]:=false;
- j:= j+1; i:= 0
- end
- else
- begin
- j:=j-1;
- if j>=1 then
- begin
- i:=x[j];
- a[i]:=true; b[i+j]:=true; c[i-j]:=true;
- if i=8 then
- begin
- j:=j-1;
- if j>=1 then
- begin
- i:=x[j];
- a[i]:=true; b[i+j]:=true; c[i-j]:=true
- end
- end
- end
- end
- until (j>8) or (j<1);
- end;
- Begin
- clrscr;
- for i:=1 to 8 do a[i]:=true;
- for i:=2 to 16 do b[i]:=true;
- for i:=-7 to 7 do c[i]:=true;
- j:=1; i:=0;
- try;
- print(x);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment