The program needs to read the values of three coordinates
as well as another coordinate P(x,
Take the average of the three given points. This new point P4 will always lie inside the triangle.
Now check if P and P4 lie on the same side of each of the three lines P1P2
P2P3
and P3P1
. You can do this by checking the signs of the cross products (P -> P1) x (P -> P2)
and (P4 -> P1) x (P4 -> P2)
(where P->P1 is the vector from P to P1), and then the other two pairs.