Advertisement
nikitaxe132

Untitled

Oct 10th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.55 KB | None | 0 0
  1. program task_2_1;
  2. uses
  3.    System.SysUtils;
  4. var
  5.    IsCorrect: Boolean;
  6.    N, I, Nomb: Byte;
  7.    A, B, C: Integer;
  8.    P, Max: Real;
  9.    Radius : array of Real;
  10. begin
  11.    Writeln('This program finds the triangle with the largest radius of the circumscribed circle');
  12.    repeat
  13.       try
  14.          WriteLn('Enter the number of triangles n(n > 2 and n < 10)');
  15.          ReadLn(N);
  16.          if (N > 10) or (N < 2) then
  17.             IsCorrect := False
  18.          else
  19.             IsCorrect := True
  20.       except
  21.          WriteLn('This is a mistake. Please enter again!');
  22.          IsCorrect:=False;
  23.       end;
  24.    until(IsCorrect) ;
  25.    SetLength(Radius, N);
  26.    N := N - 1;
  27.    Max := 0;
  28.    for I := 0 to N do
  29.    begin
  30.       repeat
  31.          try
  32.             WriteLn('Enter the sides of triangle №', (I + 1));
  33.             repeat
  34.                try
  35.                   Write('First side = ');
  36.                   Read(A);
  37.                   if (A > 0) then
  38.                      IsCorrect := True
  39.                   else
  40.                   begin
  41.                      Writeln('This is a mistake. The sides of the triangle must be positive');
  42.                      IsCorrect := False;
  43.                   end;
  44.                except
  45.                   Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
  46.                   IsCorrect := False;
  47.                end;
  48.             until(IsCorrect);
  49.             repeat
  50.                try
  51.                   Write('Second side = ');
  52.                   Read(B);
  53.                   if (B > 0) then
  54.                      IsCorrect := True
  55.                   else
  56.                   begin
  57.                      Writeln('This is a mistake. The sides of the triangle must be positive');
  58.                      IsCorrect := False;
  59.                   end;
  60.                except
  61.                   Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
  62.                   IsCorrect := False;
  63.                end;
  64.             until(IsCorrect);
  65.             repeat
  66.                try
  67.                   Write('Third side = ');
  68.                   Read(C);
  69.                   if (C > 0) then
  70.                      IsCorrect := True
  71.                   else
  72.                   begin
  73.                      Writeln('This is a mistake. The sides of the triangle must be positive');
  74.                      IsCorrect := False;
  75.                   end;
  76.                except
  77.                   Writeln('This is a mistake. The side of the triangle must be integer. Please enter side again!');
  78.                   IsCorrect := False;
  79.                end;
  80.             until(IsCorrect);
  81.             if (A + B > C) and (A + C > B) and (B + C > A) then
  82.                IsCorrect := True
  83.             else
  84.             begin
  85.                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!');
  86.                IsCorrect := False;
  87.             end;
  88.          except
  89.             Writeln('This is a mistake. The sides of the triangle must be integer. Please enter sides again!');
  90.             IsCorrect := False;
  91.          end;
  92.       until(IsCorrect) ;
  93.       P := (A + B + C) / 2;
  94.       Radius[i] := (A * B * C) / (4 * Sqrt(P * (P - A) * (P - B) * (P - C)));
  95.       if Max < Radius[i] then
  96.          begin
  97.             Max := Radius[i];
  98.             Nomb := I;
  99.          end;
  100.    end;
  101.    WriteLn('Triangle №', (Nomb + 1), ' has the largest radius of the circumscribed circle = ', Max:7:3);
  102.    ReadLn;
  103.    ReadLn;
  104. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement