标签:max stream std ace int class dir not amp
1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 struct P{ 5 int x,y; 6 }a1,a2,b1,b2; 7 int t; 8 int direct(P a,P b,P c) 9 { 10 return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); 11 } 12 bool intersect(P a1,P a2,P b1,P b2) 13 { 14 if (min(a1.x,a2.x)<=max(b1.x,b2.x)&& 15 min(b1.x,b2.x)<=max(a1.x,a2.x)&& 16 min(a1.y,a2.y)<=max(b1.y,b2.y)&& 17 min(b1.y,b2.y)<=max(a1.y,a2.y)&& 18 direct(a1,a2,b1)*direct(a1,a2,b2)<=0&& 19 direct(b1,b2,a1)*direct(b1,b2,a2)<=0) 20 return 1; 21 else 22 return 0; 23 } 24 int main() 25 { 26 scanf("%d",&t); 27 while(t--) 28 { 29 scanf("%d%d%d%d",&a1.x,&a1.y,&a2.x,&a2.y); 30 scanf("%d%d%d%d",&b1.x,&b1.y,&b2.x,&b2.y); 31 if (intersect(a1,a2,b1,b2)) 32 printf("intersect\n"); 33 else 34 printf("not intersect\n"); 35 } 36 }
标签:max stream std ace int class dir not amp
原文地址:http://www.cnblogs.com/algonote/p/7643015.html