XDUOJ 1125 Judgement of Orz Pandas

题意:判断一个点是否在三角形内。

思路:参考了博客http://blog.csdn.net/shunan/article/details/1434788

        判断点O是否在三角形ABC中,只需要判断是否满足 OA*OB,OA,OC异号并且OB*OC,OB*OA异号。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
const double eps=1e-11;
struct Point{
    double x,y;
};

Point operator-(Point a,Point b)
{
    Point c;
    c.x=a.x-b.x;
    c.y=a.y-b.y;
    return c;
}
double operator *(Point a,Point b)
{
    return a.x*b.y-a.y*b.x;
}

int main()
{
    Point a,b,c,d;
    while(cin>>a.x>>a.y)
    {
        cin>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
        if(((a-d)*(b-d))*((a-d)*(c-d))<=0&&((b-d)*(c-d))*((b-d)*(a-d))<=0)
            printf("Orz\n");
        else
            printf("stO\n");
    }
    return 0;
}
View Code

 

posted on 2015-08-27 23:29  onlyAzha  阅读(206)  评论(0编辑  收藏  举报

导航