ex105.pp 523 B

123456789101112131415161718192021222324252627
  1. Program Example105;
  2. { Program to demonstrate the IndexByte function. }
  3. Const
  4. ArraySize = 256;
  5. MaxValue = 256;
  6. Var
  7. Buffer : Array[1..ArraySize] of Byte;
  8. I,J : longint;
  9. K : Byte;
  10. begin
  11. Randomize;
  12. For I:=1 To ArraySize do
  13. Buffer[I]:=Random(MaxValue);
  14. For I:=1 to 10 do
  15. begin
  16. K:=Random(MaxValue);
  17. J:=IndexByte(Buffer,ArraySize,K);
  18. if J=-1 then
  19. Writeln('Value ',K,' was not found in buffer.')
  20. else
  21. Writeln('Found ',K,' at position ',J,' in buffer');
  22. end;
  23. end.