Page 132 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 132

100 Problems & Solutions                                               Trang 132


                      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;
                       End;
                      Procedure finish(d:diem);
                       Begin
                        A[d.hg,d.cot]:='x';
                        HienA(-10,10,-10,10);
                        Writeln('Ban da thua! An ENTER de ket thuc chuong trinh');
                        Readln;
                        Halt;
                       End;
                      Procedure Init;
                       Begin
                        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';
                        HienA(-10,10,-10,10);
                        dlt:=1;
                       End;
                      Procedure Sinh(d1:diem; Var d2:diem; hgdi,k:integer);
                      Var h,c:Integer;
                       Begin
                        h:=d1.hg; c:=d1.cot;
                        Case hgdi of
                         1: Dec(h,k);
                         2: Inc(c,k);
                        -1: Inc(h,k);
                        -2: Dec(c,k);
                        End;
                        d2.hg:=h; d2.cot:=c;
                       End;
                      Function kt(Var d1,d2:diem):boolean;
                      Var g1,g,g2:diem;
                          k,p:integer;
                       Begin
                        kt:=true;
                        k:=(dlt-1) div 2;
                        p:=2 div abs(hgdi);
                        sinh(dmay,g1,-hgdi,k);
                        sinh(dmay,g2,-hgdi,2*k);
                        sinh(g1,g,p,k);



                      Tin học & Nhà trường                                       100 Đề Toán - Tin học
   127   128   129   130   131   132   133   134   135   136   137