Advertisement
iordan_93

Triangle

Apr 14th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. class Triangle
  3. {
  4.     static void Main()
  5.     {
  6.         int ax = int.Parse(Console.ReadLine());
  7.         int ay = int.Parse(Console.ReadLine());
  8.         int bx = int.Parse(Console.ReadLine());
  9.         int by = int.Parse(Console.ReadLine());
  10.         int cx = int.Parse(Console.ReadLine());
  11.         int cy = int.Parse(Console.ReadLine());
  12.  
  13.         double a = Math.Sqrt(Math.Pow(bx - ax, 2) + Math.Pow(by - ay, 2));
  14.         double b = Math.Sqrt(Math.Pow(cx - bx, 2) + Math.Pow(cy - by, 2));
  15.         double c = Math.Sqrt(Math.Pow(cx - ax, 2) + Math.Pow(cy - ay, 2));
  16.  
  17.         if (a + b > c && b + c > a && a + c > b)
  18.         {
  19.             Console.WriteLine("Yes");
  20.             double p = (a + b + c) / 2;
  21.             double area = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
  22.             Console.WriteLine("{0:0.00}", area);
  23.         }
  24.         else
  25.         {
  26.             Console.WriteLine("No");
  27.             Console.WriteLine("{0:0.00}", a);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement