16,746
社区成员




type
TMyArray = array[0..16] of Word;
function ExpandArray(A: TMyArray; L: Integer): TMyArray;
var
i : Integer;
begin
A[0] := 0;
A[16] := 0;
FillChar(Result, SizeOf(Result), 0);
for i := 1 to L do
Result[i] := (A[i] shr i) or (A[i-1] shl (16 - i)) or $8000;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
R, W: TFileStream;
A, B: TMyArray;
L : Integer;
begin
R := TFileStream.Create('d:\1', fmOpenRead);
try
W := TFileStream.Create('d:\2', fmCreate);
try
R.Position := 0;
repeat
FillChar(A, SizeOf(A), 0);
L := R.Read(A[1], 30);
if L > 0 then
begin
if odd(L) then inc(L);
B := ExpandArray(A, L);
W.WriteBuffer(B[1], L + 2);
end;
until L < 30;
finally
W.Free;
end;
finally
R.Free;
end;
end;