1372Problem B:几何题(一)

来源:互联网 发布:中国户外刀代工知乎 编辑:程序博客网 时间:2024/05/16 01:49
#include<stdio.h>//  作者: 许同学 double direction( double x1,double y1,double x2,double y2,double x0,double y0 )   //直线方向是由(x1,y1)到(x2,y2)的方向{    double a,b,c,d;    a=y2-y1;    b=x1-x2;    c=x2*y1-x1*y2;    d=a*x0+b*y0+c;    return d;           //若d<0,则点P在直线的左侧,若d>0,则点P在直线的右侧,若d=0,则点P在直线上}int main(){    int t;    double x1,y1,x2,y2,x3,y3,x4,y4,x0,y0;    double a1,a2,a3,a4;    scanf("%d",&t);    while(t--)    {        scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&x0,&y0);        a1=direction( x1,y1,x2,y2,x0,y0 );        a2=direction( x2,y2,x3,y3,x0,y0 );        a3=direction( x3,y3,x4,y4,x0,y0 );        a4=direction( x4,y4,x1,y1,x0,y0);        if(a1<0&&a2<0&&a3<0&&a4<0 ||a1>0&&a2>0&&a3>0&&a4>0 )           printf("T\n");        else           printf("F\n");    }    return 0;}