From d632d74ddd2336893be77d0430afe1f8f111f6ec Mon Sep 17 00:00:00 2001 From: IsuminI <149383661+IsuminI@users.noreply.github.com> Date: Wed, 10 Jul 2024 01:01:04 +0900 Subject: [PATCH] 17386 --- .../17386.c" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "\354\235\264\354\210\230\353\257\274/17386.c" diff --git "a/\354\235\264\354\210\230\353\257\274/17386.c" "b/\354\235\264\354\210\230\353\257\274/17386.c" new file mode 100644 index 00000000..28b6b065 --- /dev/null +++ "b/\354\235\264\354\210\230\353\257\274/17386.c" @@ -0,0 +1,29 @@ +#include +#include +typedef struct { + long long int x,y; +}st; +int ccw(st p1, st p2, st p3) { + long long int s = (p1.x*p2.y + p2.x*p3.y + p3.x*p1.y) - (p1.x*p3.y + p2.x*p1.y + p3.x*p2.y); + if(s > 0) return 1; + else if(s == 0) return 0; + return -1; +} +int isCross(st p1, st p2, st p3, st p4) { + int p1p2 = ccw(p1, p2, p3) * ccw(p1, p2, p4); + int p3p4 = ccw(p3, p4, p1) * ccw(p3, p4, p2); + return p1p2 <= 0 && p3p4 <= 0; +} +int main() +{ + int x1,x2,x3,x4,y1,y2,y3,y4; + scanf("%d %d %d %d",&x1,&y1,&x2,&y2); + scanf("%d %d %d %d",&x3,&y3,&x4,&y4); + st p1 = {x1, y1}; + st p2 = {x2, y2}; + st p3 = {x3, y3}; + st p4 = {x4, y4}; + + printf("%d",isCross(p1, p2, p3, p4)); + return 0; +}