//Point p1,p2是线段的端点。Point p3,p4是直线上的两个点。
typedef struct {
double x,y;
} Point;
int lineintersect(Point p1,Point p2,Point p3,Point p4)
{
Point tp1,tp2,tp3;
tp1.x=p1.x-p3.x;
tp1.y=p1.y-p3.y;
tp2.x=p4.x-p3.x;
tp2.y=p4.y-p3.y;
tp3.x=p2.x-p3.x;
tp3.y=p2.y-p3.y;
if ((tp1.x*tp2.y-tp1.y*tp2.x)*(tp2.x*tp3.y-tp2.y*tp3.x)>=0) return 1; else return 0;
}