Program.cs 712 B

123456789101112131415161718192021222324
  1. int[] x = new int[4];
  2. int[] y = new int[4];
  3. for (int i = 0; i < 4; ++i)
  4. {
  5. Console.WriteLine("Введите (x" + i.ToString() + ",y" + i.ToString() + "): ");
  6. x[i] = Console.Read();
  7. y[i] = Console.Read();
  8. Console.ReadLine();
  9. }
  10. int a = (x[1] - x[0]) * (y[2] - y[1]) - (x[2] - x[1]) * (y[1] - y[0]);
  11. int b = (x[2] - x[0]) * (y[3] - y[2]) - (x[3] - x[2]) * (y[2] - y[0]);
  12. int c = (x[3] - x[0]) * (y[1] - y[3]) - (x[1] - x[3]) * (y[3] - y[0]);
  13. if ((a >= 0 && b >= 0 && c >= 0) || (a <= 0 && b <= 0 && c <= 0))
  14. {
  15. Console.WriteLine("Принадлежит треугольнику");
  16. }
  17. else
  18. {
  19. Console.WriteLine("Не принадлежит треугольнике");
  20. }
  21. Console.ReadKey();