2. Neu co 2k+1(k>=1) o lien canh lien tiep thi kiem tra co the gianh thang
loi bang nuoc do^i khong? Nuoc do^i la nuoc ta danh vao 1 o nhung co the co duoc 2 hinh vuong. vi du: co
3 o (1,1);(1,2);(1,3) thi ta co the danh nuoc doi bang cach danh vao o (2,2) nhu vay ta co kha nang hinh
thanh 2 o vuong. Nhung sau 1 nuoc di doi thi chi duy nhat chan duoc 1 o vuong, ta co the danh nuoc tiep
theo de hinh thanh o vuong con lai va gianh duoc thang loi.
Bang cach danh nhu vay ban co the chien thang trong vong toi da la 10 nuoc.*)
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V+,X+}
{$M 16384,0,655360}
CONST Min=-50;
Max=50;
TYPE Ma=Array[Min..Max,Min..Max] of char;
diem= Record
hg,cot:Integer;
End;
Qu=Array[1..Max] of diem;
VAR dmay,dng,dc1,dc2:diem;
hgdi:Integer; (*1:B ; 2:D ; -1:N ; -2:T*)
fin,ok:Boolean;
A:Ma;
Q,Qc:Qu;
dlt,dq,cq:Integer;
Procedure HienA(hgd,hgc,cotd,cotc:Integer);
Var i,j:Integer;
Begin
For i:=hgd to hgc do
Begin
For j:=cotd to cotc do Write(A[i,j],' ');
Writeln;
End;
Procedure finish(d:diem);
A[d.hg,d.cot]:='x';
HienA(-10,10,-10,10);
Writeln('Ban da thua! An ENTER de ket thuc chuong trinh');
Readln;
Halt;
Procedure Init;
Fillchar(A,sizeof(A),'.');
fin:=false;
Writeln('Gia thiet bang o vuong co: 101 hang (-50 -> 50)');
Writeln(' 101 cot (-50 -> 50)');
Writeln('Gia thiet may luon di nuoc dau tien tai o co toa do (0:0)');
dmay.hg:=0; dmay.cot:=0; A[dmay.hg,dmay.cot]:='X';
dlt:=1;
Procedure Sinh(d1:diem; Var d2:diem; hgdi,k:integer);
Var h,c:Integer;
h:=d1.hg; c:=d1.cot;
Case hgdi of
Bạn đang xem 2. - 100 DE TIN HSG CO DAP AN