Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program task_2_1;
- uses
- System.SysUtils;
- var
- IsCorrect: Boolean;
- N, I, Nomb: Byte;
- A, B, C: Integer;
- P, Max: Real;
- Radius : array of Real;
- begin
- Writeln('This program finds the triangle with the largest radius of the circumscribed circle');
- repeat
- try
- WriteLn('Enter the number of triangles n(n > 2 and n < 10)');
- ReadLn(N);
- if (N > 10) or (N < 2) then
- IsCorrect := False
- else
- IsCorrect := True
- except
- WriteLn('This is a mistake. Please enter again!');
- IsCorrect:=False;
- end;
- until(IsCorrect) ;
- SetLength(Radius, N);
- N := N - 1;
- Max := 0;
- for I := 0 to N do
- begin
- repeat
- try
- WriteLn('Enter the sides of triangle №', (I + 1));
- repeat
- try
- Write('First side = ');
- Read(A);
- if (A > 0) then
- IsCorrect := True
- else
- begin
- Writeln('This is a mistake. The sides of the triangle must be positive');
- IsCorrect := False;
- end;
- except
- Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
- IsCorrect := False;
- end;
- until(IsCorrect);
- repeat
- try
- Write('Second side = ');
- Read(B);
- if (B > 0) then
- IsCorrect := True
- else
- begin
- Writeln('This is a mistake. The sides of the triangle must be positive');
- IsCorrect := False;
- end;
- except
- Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
- IsCorrect := False;
- end;
- until(IsCorrect);
- repeat
- try
- Write('Third side = ');
- Read(C);
- if (C > 0) then
- IsCorrect := True
- else
- begin
- Writeln('This is a mistake. The sides of the triangle must be positive');
- IsCorrect := False;
- end;
- except
- Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
- IsCorrect := False;
- end;
- until(IsCorrect);
- if (A + B > C) and (A + C > B) and (B + C > A) then
- IsCorrect := True
- else
- begin
- Writeln('This is a mistake. The sides of the triangle must satisfy the condition (a + b > c and a + c > b and b + c > a).Please enter sides again!');
- IsCorrect := False;
- end;
- except
- Writeln('This is a mistake. The sides of the triangle must be integer. Please enter sides again!');
- IsCorrect := False;
- end;
- until(IsCorrect) ;
- P := (A + B + C) / 2;
- Radius[i] := (A * B * C) / (4 * Sqrt(P * (P - A) * (P - B) * (P - C)));
- if Max < Radius[i] then
- begin
- Max := Radius[i];
- Nomb := I;
- end;
- end;
- WriteLn('Triangle №', (Nomb + 1), ' has the largest radius of the circumscribed circle = ', Max:7:3);
- ReadLn;
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement