tw38129.pp 440 B

123456789101112131415161718192021
  1. { %opt=-O3 }
  2. {$mode objfpc}
  3. {$H+}
  4. function Bar(const progress: single; divs: uint32): string;
  5. const
  6. BarSym: array[boolean] of char = ('.', '#');
  7. var
  8. i: int32;
  9. begin
  10. SetLength(result, divs);
  11. for i := 0 to int32(divs) - 1 do
  12. pChar(result)[i] := BarSym[(progress >= (0.75 + i) / divs) or (i = int32(divs) - 1) and (progress >= 1)];
  13. end;
  14. var
  15. s: string;
  16. begin
  17. if Bar(0.7, 10)<>'#######...' then
  18. halt(1);
  19. end.