#include #include typedef struct { int a[2],b[2],c[2]; } triangle; static inline void vsub(int d[], int s[], int t[]) { d[0] = s[0] - t[0]; d[1] = s[1] - t[1]; } static int ext_product(int s[], int t[]) { return s[0] * t[1] - s[1] * t[0]; } static int sign(int x) { if (x < 0) return -1; if (x > 0) return 1; return 0; } bool o_in_tri(triangle *t) { int ab[2], ac[2], bc[2]; vsub(ab, t->b, t->a); vsub(ac, t->c, t->a); vsub(bc, t->c, t->b); /* sig(ABxAC) = sig(OBxOC) */ int sabc = sign(ext_product(ab, ac)); int sobc = sign(ext_product(t->b, t->c)); if (sabc != sobc) return false; /* sig(BAxBC) = sig(OAxOC) */ int sbac = sign(ext_product(bc, ab)); int soac = sign(ext_product(t->a, t->c)); if (sbac != soac) return false; /* sig(CAxCB) = sig(OAxOB) */ int scab = sign(ext_product(ac, bc)); int soab = sign(ext_product(t->a, t->b)); if (scab != soab) return false; return true; } int main() { triangle t; int n = 0; /* the data uses ',' to split the integers, process it with * sed 's/,/ /g' first. */ while (scanf("%d%d%d%d%d%d", &t.a[0], &t.a[1], &t.b[0], &t.b[1], &t.c[0], &t.c[1]) != EOF) { if (o_in_tri(&t)) n++; } printf("%d\n", n); }