Advertisement
Ruslan-7E

triangle square

Feb 19th, 2021
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1.             Console.WriteLine("Let's calculate the square of a triangle");
  2.  
  3.             Console.WriteLine("Enter the length of side AB:");
  4.             double ab = double.Parse(Console.ReadLine());
  5.  
  6.             Console.WriteLine("Enter the length of side BC:");
  7.             double bc = double.Parse(Console.ReadLine());
  8.  
  9.             Console.WriteLine("Enter the length of side AC:");
  10.             double ac = double.Parse(Console.ReadLine());
  11.  
  12.             double p = (ab + bc + ac) / 2; // вычисляем полупериметр треугольника
  13.  
  14.             double square = Math.Sqrt(p * (p - ab) * (p - bc) * (p - ac)); // находим площадь по формуле Герона
  15.             Console.WriteLine($"Square of the triangle equals {square}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement