Page 73 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 73
100 Problems & Solutions Trang 73
tg:=A[k,6];
for i:=3 downto 1 do A[k,0] := A[k,2*i-2];
A[k,0]:=tg;
tg:=A[k,7];
for i:=3 downto 1 do A[k,2*i] := A[k,2*i -2];
A[k,1]:=tg;
for i:=1 to 3 do
begin
tg:=A[dir[k,0,3], Dir[k,i,3];
for j:=3 downto 1 do A[ dir[k,0,j], Dir[k,i,j] ]:= A[ dir[k,0,j-1], Dir[k,i,j-1] ];
A[ [dir[k,0,0], Dir[k,i,0] ]:=tg;
end;
End;
Function Eq(A,B:Arr):Boolean;
Var i,j,c:byte;
Begin
c:=0;
for i:=1 to 5 do
for j:=1 to 7 do
If A[i,j] <> B[i,j] then inc(c);
If c=0 then Eq:=true else Eq:=false;
End;
Procedure QuayXau(x:string; var A: arr);
Var i,j:byte;
Begin
for i:=1 to length(X) do
begin
for j:= 1 to 5 do
If Color[j] = X[i] then Quay(A,j);
end;
End;
Procedure Bai1;
Begin
QuayXau(X1,A1);
QuayXau(X2,A2);
End;
Procedure Bai2;
Begin
k:=0;
Repeat
QuayXau(X,A);
Inc(k);
Until Eq(A,A0);
End;
Procedure Xuat;
Var i,j:byte;
Begin
writeln;
writeln('Ket qua:');
writeln('Bai toan 1. So sanh 2 xau:') ;
Tin học & Nhà trường 100 Đề Toán - Tin học