Page 101 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 101
100 Problems & Solutions Trang 101
Begin
k:=i div 8;
i:=i mod 8;
Laybit:=(a[k] shr (7-i)) and 1;
End;
PROCEDURE Tatbit(i:word);
Var k:word;
Begin
k:=i div 8;
i:=i mod 8;
a[k]:=a[k] and (not (1 shl (7-i)));
End;
FUNCTION Tim(j:word):word;
Begin
While (laybit(j+1)=0) do
begin
If j=max-1 then j:=0
else inc(j);
end;
Tim:=j+1;
End;
PROCEDURE Xuly;
Var j,dem,i :word;
Begin
j:=1;dem:=0;
Fillchar(a,sizeof(a),255);
Tatbit(0);
Repeat
If j=max then j:=0;
j:=tim(j);
Tatbit(j);
inc(dem);
If j=max then j:=0;
j:=tim(j);
Until dem=max-1;
For i:=0 to (max div 8) do
If a[i]<>0 then break;
so:=i * (1 shl 3);
For i:=so to so+7 do
If Laybit(i)=1 then break;
so:=i;
Writeln(' SO TIM DUOC LA :',SO:4);
Writeln(' Press Enter to Stop.....');
readln;
End;
BEGIN
Tin học & Nhà trường 100 Đề Toán - Tin học