Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. program laboratornaya_1;
  2.  
  3. uses
  4. System.SysUtils,
  5. System.Math;
  6.  
  7. var
  8. Input: string = '';
  9. Result: Real = Infinity;
  10. First: Real = 0;
  11. Second: Real = 0;
  12. Third: Real = 0;
  13. Division: Real = 0;
  14. IsCorrect: Boolean = False;
  15.  
  16. begin
  17. Writeln('This program calculates the least ratio of numbers');
  18. repeat
  19. Write('Enter number #1: ');
  20. try
  21. Readln(Input);
  22. First := StrToFloat(Input);
  23. if(First <> Infinity) then
  24. IsCorrect := True
  25. else
  26. Writeln('ErrorMessage');
  27. except
  28. Writeln('ErrorMessage');
  29. end;
  30. until IsCorrect;
  31. IsCorrect := False;
  32. repeat
  33. Write('Enter number #2: ');
  34. try
  35. Readln(Input);
  36. Second := StrToFloat(Input);
  37. if(Second <> Infinity) then
  38. IsCorrect := True
  39. else
  40. Writeln('ErrorMessage');
  41. except
  42. Writeln('ErrorMessage');
  43. end;
  44. until IsCorrect;
  45. IsCorrect := False;
  46. repeat
  47. Write('Enter number #3: ');
  48. try
  49. Readln(Input);
  50. Third := StrToFloat(Input);
  51. if(Third <> Infinity) then
  52. IsCorrect := True
  53. else
  54. Writeln('ErrorMessage');
  55. except
  56. Writeln('ErrorMessage');
  57. end;
  58. until IsCorrect;
  59. if(First <> 0) then
  60. begin
  61. Division := IfThen(Second / First < Third / First, Second / First, Third / First);
  62. if(Division < Result) then
  63. Result := Division;
  64. end;
  65. if(Second <> 0) then
  66. begin
  67. Division := IfThen(First / Second < Third / Second, First / Second, Third / Second);
  68. if(Division < Result) then
  69. Result := Division;
  70. end;
  71. if(Third <> 0) then
  72. begin
  73. Division := IfThen(First / Third < Second / Third, First / Third, Second / Third);
  74. if(Division < Result) then
  75. Result := Division;
  76. end;
  77. if(Result = Infinity) then
  78. Writeln('Result: Infinity')
  79. else
  80. Writeln('Result: ', Result:Length(IntToStr(Floor(Result))) + 6:5);
  81. readln;
  82.  
  83. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement