ex89.pp 793 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. Program Example89;
  2. { This program demonstrates the FormatFloat function }
  3. Uses sysutils;
  4. Const
  5. NrFormat=9;
  6. FormatStrings : Array[1..NrFormat] of string = (
  7. '',
  8. '0',
  9. '0.00',
  10. '#.##',
  11. '#,##0.00',
  12. '#,##0.00;(#,##0.00)',
  13. '#,##0.00;;Zero',
  14. '0.000E+00',
  15. '#.###E-0');
  16. NrValue = 5;
  17. FormatValues : Array[1..NrValue] of Double =
  18. (1234,-1234,0.5,0,-0.5);
  19. Width = 12;
  20. FWidth = 20;
  21. Var
  22. I,J : Integer;
  23. S : String;
  24. begin
  25. Write('Format':FWidth);
  26. For I:=1 to NrValue do
  27. Write(FormatValues[i]:Width:2);
  28. Writeln;
  29. For I:=1 to NrFormat do
  30. begin
  31. Write(FormatStrings[i]:FWidth);
  32. For J:=1 to NrValue do
  33. begin
  34. S:=FormatFloat(FormatStrings[I],FormatValues[j]);
  35. Write(S:Width);
  36. end;
  37. Writeln;
  38. end;
  39. End.