Skip to content

Instantly share code, notes, and snippets.

@unilecs
Created March 7, 2018 06:59
Show Gist options
  • Save unilecs/8ce7f1217a6323e9aacb863dae3a9450 to your computer and use it in GitHub Desktop.
Save unilecs/8ce7f1217a6323e9aacb863dae3a9450 to your computer and use it in GitHub Desktop.
Задача 77: Площадь четырехугольника
using System;
public class Program
{
// Формула Герона для вычисления площади треугольника abc
public static double AreaByHeronFormula(double a, double b, double c)
{
double p = (a + b + c) / 2.0;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public static void Main()
{
Console.WriteLine("UniLecs");
Console.WriteLine(string.Format("Answer = {0}", AreaByHeronFormula(3, 4, 5) + AreaByHeronFormula(4, 2, 5))); // ~9.8
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment