Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program laboratornaya_1;
- uses
- System.SysUtils,
- System.Math;
- var
- Input: string = '';
- Result: Real = Infinity;
- First: Real = 0;
- Second: Real = 0;
- Third: Real = 0;
- Division: Real = 0;
- IsCorrect: Boolean = False;
- begin
- Writeln('This program calculates the least ratio of numbers');
- repeat
- Write('Enter number #1: ');
- try
- Readln(Input);
- First := StrToFloat(Input);
- if(First <> Infinity) then
- IsCorrect := True
- else
- Writeln('ErrorMessage');
- except
- Writeln('ErrorMessage');
- end;
- until IsCorrect;
- IsCorrect := False;
- repeat
- Write('Enter number #2: ');
- try
- Readln(Input);
- Second := StrToFloat(Input);
- if(Second <> Infinity) then
- IsCorrect := True
- else
- Writeln('ErrorMessage');
- except
- Writeln('ErrorMessage');
- end;
- until IsCorrect;
- IsCorrect := False;
- repeat
- Write('Enter number #3: ');
- try
- Readln(Input);
- Third := StrToFloat(Input);
- if(Third <> Infinity) then
- IsCorrect := True
- else
- Writeln('ErrorMessage');
- except
- Writeln('ErrorMessage');
- end;
- until IsCorrect;
- if(First <> 0) then
- begin
- Division := IfThen(Second / First < Third / First, Second / First, Third / First);
- if(Division < Result) then
- Result := Division;
- end;
- if(Second <> 0) then
- begin
- Division := IfThen(First / Second < Third / Second, First / Second, Third / Second);
- if(Division < Result) then
- Result := Division;
- end;
- if(Third <> 0) then
- begin
- Division := IfThen(First / Third < Second / Third, First / Third, Second / Third);
- if(Division < Result) then
- Result := Division;
- end;
- if(Result = Infinity) then
- Writeln('Result: Infinity')
- else
- Writeln('Result: ', Result:Length(IntToStr(Floor(Result))) + 6:5);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement