Go: package main

import "fmt"

func main() {
	var x1, x2, x3, y1, y2, y3, xp, yp float64
	for {
		v, _ := fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)
		// println(x1, x2, x3, y1, y2, y3, xp, yp)
		if v != 8 {
			break
		}
		ok1 := true
		ok2 := true
		if (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if (x3-x2)*(yp-y2)-(xp-x2)*(y3-y2)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if (x1-x3)*(yp-y3)-(xp-x3)*(y1-y3)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if ok1 || ok2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

bool m(double a1, double b1, double a2, double b2){
	bool key;

	if(a1==0){
		if(a2==0) key=true;
		else key=false;
	}
	else{
		if(a2==0) key=false;
		else{
			if(b1/a1==b2/a2) key=true;
			else key=false;		
		}
	}

	return key;
}

int main(){
	double x1,x2,x3,xp,y1,y2,y3,yp;
	while( scanf(" %lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF ){
		
		//(x1,y1)が原点に来るように平行移動
		x2-=x1; y2-=y1; x3-=x1; y3-=y1; xp-=x1; yp-=y1;
		x1-=x1; y1-=y1;
		
		//printf(" %lf %lf %lf %lf %lf %lf %lf %lf\n", x1, y1, x2, y2, x3, y3, xp, yp);
		
		bool ans;
		
		//(xp,yp)が辺の延長線上にあるとき
		if(m(x2,y2,xp,yp) || m(x3,y3,xp,yp)){
			ans=false;
		}
		else{
			double p, q;
			
			if(x2!=0){
				q=(yp-xp*y2/x2)/(y3-x3*y2/x2);
				p=(xp-q*x3)/x2;
			}
			else{
				q=xp/x3;
				p=(yp-q*y3)/y2;
			}
		
			//printf("p=%lf, q=%lf\n",p ,q);
		
			if(0<p && p<1 && 0<q && q<1 && p+q<1) ans= true;
			else ans=false;
		}
		
		if(ans) printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
double x[4],y[4],px,py,ax,ay,bx,by;
int main()
{
	while(true)
	{
		for(int i = 1;i<=3;i++){cin >> x[i];cin >> y[i];}
		if(cin.eof())break;
		cin >> px;
		cin >> py;
		double m,n,s;
		ax = x[2]-x[1];
		ay = y[2]-y[1];
		bx = x[3]-x[1];
		by = y[3]-y[1];
		double det = ax*by-ay*bx;
		m = (by*px-bx*py)/det;
		n = (-ay*px+ax*py)/det;
		if((m+n)<1&&m>0 && n > 0&& m<1 && n < 1) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>

class Point2d {
private:
	double x, y;
public:
	void set(double x, double y) { this->x = x; this->y = y; }
	double X() { return this->x; }
	double Y() { return this->y; }
	Point2d operator+(Point2d &p) {
		Point2d result;
		result.set(this->x + p.X(), this->y + p.Y());
		return result;
	}
	Point2d operator-(Point2d &p) {
		Point2d result;
		result.set(this->x - p.X(), this->y - p.Y());
		return result;
	}
	Point2d operator*(double a) {
		Point2d result;
		result.set(this->x * a, this->y * a);
		return result;
	}
	/* ¼ü p1p2 Æüª q1q2 ªðíÁÄ¢êÎ true ðÔ· */
	static bool interectLine(Point2d &p1, Point2d &p2, Point2d &q1, Point2d &q2) {
		Point2d p = p2 - p1, pq1 = q1 - p1, pq2 = q2 - p1;
		double tmp1, tmp2, t1z;
		tmp1 = p.X() * pq1.Y() - p.Y() * pq1.X();	/* p Æ pq1 ÌOÏÌz¬ª */
		tmp2 = p.X() * pq2.Y() - p.Y() * pq2.X();	/* p Æ pq2 ÌOÏÌz¬ª */
		t1z = tmp1 * tmp2;	/* OÏÌü«ªá¦Î¼ü p1p2 Æüª q1q2 ÍðíÁÄ¢é */
		return t1z <= 0.;
	}
	/* üª p1p2 Æüª q1q2 ªðíÁÄêÎ true ðÔ· */
	static bool interect(Point2d &p1, Point2d &p2, Point2d &q1, Point2d &q2) {
		return interectLine(p1, p2, q1, q2) && interectLine(q1, q2, p1, p2);
	}
	/* _ p ª¼ü q1q2 ãÉ êÎ true ðÔ· */
	static bool pointInLine(Point2d &p, Point2d &q1, Point2d &q2) {
		Point2d l1 = q1 - p, l2 = q2 - p;
		double crossZ = l1.X() * l2.Y() - l1.Y() * l2.X();
		return crossZ == 0.;
	}
};

int main() {
	using namespace std;
	double x[3], y[3], xp, yp, xq, yq;
	Point2d ptR[3], ptP, ptQ;
	int count;

	while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
		for (int i = 0; i < 3; ++i) {
			ptR[i].set(x[i], y[i]);
		}
		ptP.set(xp, yp);
		xq = x[0];
		for (int i = 1; i < 3; ++i) {
			if (x[i] > xq) { xq = x[i]; }
		}
		xq += (double)(rand() % 100 + 10) * 0.1;
		for (;;) {
			yq = yp + (double)((rand() % 100) - 50) * 0.1;
			ptQ.set(xq, yq);

			bool flag = false;
			for (int i = 0; i < 3; ++i) {
				if (Point2d::pointInLine(ptR[i], ptP, ptQ)) { flag = true; }
			}
			if (!flag) { break; }
		}

		count = 0;
		for (int i = 0; i < 3; ++i) {
			if (Point2d::interect(ptP, ptQ, ptR[i], ptR[(i + 1) % 3])) {
				++count;
			}
		}
		cout << (((count & 1) != 0) ? "YES" : "NO") << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;

struct vec2
{
	double x;
	double y;
};

//2次元ベクトル外積
double Outer_products(const vec2 (&a)[2]) {
	return (a[0].x * a[1].y - a[0].y * a[1].x);
}

//符号判定  '+' is (1) , '-' is (-1) , '0' is (0)
double Sign(const double &p) {
	return (p > 0) - (p < 0);
}

//３つの引数の符号が同じ場合true
bool Is_all_three(const double (&check)[3]) {
	int cnt = 0;
	for (int i = 0; i < 3; ++i) {
		cnt += Sign(check[i]);
	}
	return (abs(cnt) == 3) ? true : false;
}

int main() {
	vec2 ver[3];
	vec2 p;
	vec2 tmp[2];
	double check[3];

	while (true) {
		if (cin.eof())break;
		for (int i = 0; i < 3; ++i) {
			cin >> ver[i].x;
			cin >> ver[i].y;
		}
		cin >> p.x >> p.y;

		for (int i = 0; i < 3; ++i) {
			tmp[0].x = ver[(i + 1) % 3].x - ver[i].x;
			tmp[0].y = ver[(i + 1) % 3].y - ver[i].y;
			tmp[1].x = p.x - ver[i].x;
			tmp[1].y = p.y - ver[i].y;
			check[i] = Outer_products(tmp);
		}
		if (Is_all_three(check)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	
	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
struct vect{
  double x,y;
};
double leng(vect a,vect b){
  return sqrt((a.x - b.x)*(a.x - b.x)+(a.y - b.y)*(a.y - b.y));
    }
double Sc(vect a,vect b,vect c){
  double S,l1,l2,l3; 
  l1 = leng(a,b);
  l2 = leng(b,c);
  l3 = leng(c,a);
  S = (l1 + l2 + l3) / 2;
  return sqrt(S*(S-l1)*(S-l2)*(S-l3));
  
}

int main(){
  vect a,b,c,p;
  double s1,s2,s3,s;
  while(cin >> a.x >> a.y  >> b.x >> b.y >>c.x >>c.y >> p.x >> p.y){
    s1 = Sc(a,b,p); s2 = Sc(a,p,c); s3 = Sc(p,b,c); 
    s = Sc(a,b,c);
    if( Sc(a,b,p) + Sc(a,p,c) < Sc(a,b,c)&&Sc(p,b,c) + Sc(a,p,c) < Sc(a,b,c) && Sc(a,b,p) + Sc(p,b,c) < Sc(a,b,c) ){cout << "YES" << endl;
    }else {cout << "NO" << endl;}
    
  }
}

C++: #include <iostream>
#include <cmath>
#define eps 1e-9
using namespace std;
typedef struct
{
    double x;
    double y;
}Point;
double area(Point a,Point b,Point c)
{
    return a.x*b.y+c.x*a.y+b.x*c.y-c.x*b.y-a.x*c.y-b.x*a.y;
}
int main()
{
    Point a,b,c,tar;
    while(cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>tar.x>>tar.y)
    {
        double sum=abs(area(a,b,c));
        double cmp=abs(area(a,b,tar))+abs(area(a,c,tar))+abs(area(b,c,tar));
        if(fabs(sum-cmp)<eps)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

struct TPoint
{
	double x;
	double y;
};

double GetCrossProduct(const TPoint& V1, const TPoint& V2)
{
	return V1.x * V2.y - V1.y * V2.x;
}

double Vector(const TPoint& P1, const TPoint& P2)
{
	return {P2.x - P1.x, P2.y - P1.y};
}

bool IsSameSide(const TPoint& P1, const TPoint& P2, const TPoint& L1, const TPoint& L2)
{
	return GetCrossProduct(Vector(L1, P1), Vector(L1, L2)) * GetCrossProduct(Vector(L1, P2), Vector(L1, L2)) > 0;
}

int main()
{
	while(true){
		TPoint A1, A2, A3, Ap;
		cin >> A1.x >> A1.y >> A2.x >> A2.y >> A3.x >> A3.y >> Ap.x >> Ap.y;
		if(cin.eof() == true) break;
		if(IsSameSide(A3, Ap, A1, A2) && IsSameSide(A1, Ap, A2, A3) && IsSameSide(A2, Ap, A3, A1)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}