Company: Greyorange
Difficulty: medium
9. Do They Belong? A triangle formed by the three points a(x1, y1), b(x2, y2) and c(x3, y3) is a non-degenerate triangle if the following rules are respected (|ab| is the length of the line between points a and b): |ab| + |bc| > |ac| |bc| + |ac| > |ab| |ab| + |ac| > |bc| A point belongs to a triangle if it lies somewhere on or inside the triangle. Given two points p = (xp, yp) and q = (xq, yq), return the correct scenario number: 0: If the triangle abc does not form a valid non-degenerate triangle. 1: If point p belongs to the triangle but point q does not. 2: If point q belongs to the triangle but point p does not. 3: If both points p and q belong to the triangle. 4: If neither point p nor point q belong to the triangle. Function Description Complete the function pointsBelong with the following parameter(s): int x1, y1, x2, y2, x3, y3 : integer coordinates of the three points that may create a valid triangle int xp, yp, xq, yq : integer coordinates of the two points p and q Returns: i