Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Triangle
- {
- static void Main()
- {
- int aX = int.Parse(Console.ReadLine());
- int aY = int.Parse(Console.ReadLine());
- int bX = int.Parse(Console.ReadLine());
- int bY = int.Parse(Console.ReadLine());
- int cX = int.Parse(Console.ReadLine());
- int cY = int.Parse(Console.ReadLine());
- decimal lineA = calculateLine(bX, aX, bY, aY);
- decimal lineB = calculateLine(cX, bX, cY, bY);
- decimal lineC = calculateLine(cX, aX, cY, aY);
- if (isTriangle(lineA,lineB,lineC))
- {
- Console.WriteLine("Yes");
- decimal p = (lineA + lineB + lineC) / 2;
- decimal area = (decimal)Math.Sqrt((double)p * (double)(p - lineA) * (double)(p - lineB) * (double)(p - lineC));
- Console.WriteLine("{0:f2}",area);
- }
- else
- {
- Console.WriteLine("No");
- Console.WriteLine("{0:f2}",calculateLine(aX,bX,aY,bY));
- }
- }
- static decimal calculateLine(int x2, int x1, int y2, int y1)
- {
- decimal line = (decimal)Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
- return line;
- }
- static bool isTriangle(decimal a, decimal b, decimal c)
- {
- bool isTriangle = a + b > c && b + c > a && a + c > b;
- return isTriangle;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement