Advertisement
Kolimnared

Triangle

Oct 17th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. class Triangle
  4. {
  5. private static double findDistance(int x1, int y1, int x2, int y2) {
  6. return Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
  7. }
  8.  
  9. static void Main(string[] args)
  10. {
  11. int Ax = int.Parse(Console.ReadLine());
  12. int Ay = int.Parse(Console.ReadLine());
  13. int Bx = int.Parse(Console.ReadLine());
  14. int By = int.Parse(Console.ReadLine());
  15. int Cx = int.Parse(Console.ReadLine());
  16. int Cy = int.Parse(Console.ReadLine());
  17.  
  18. double AB = findDistance(Ax, Ay, Bx, By);
  19. double AC = findDistance(Ax, Ay, Cx, Cy);
  20. double BC = findDistance(Bx, By, Cx, Cy);
  21.  
  22. if (AB + BC > AC && AB + AC > BC && AC + BC > AB)
  23. {
  24. double p = (AB + AC + BC) / 2;
  25. double area = Math.Sqrt(p * (p - AB) * (p - AC) * (p - BC));
  26.  
  27. Console.WriteLine("Yes");
  28. Console.WriteLine("{0:F2}", area);
  29. }
  30. else
  31. {
  32. Console.WriteLine("No");
  33. Console.WriteLine("{0:F2}", AB);
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement