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>
using namespace std;

bool judge(double x1, double x2, double x3, double y1, double y2, double y3, double xp, double yp)
{
    if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) > 0)
    {
        if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) > 0)
        {
            if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) > 0)
            {
                return true;
            }
        }
    }
    if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) < 0)
    {
        if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) < 0)
        {
            if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) < 0)
            {
                return true;
            }
        }
    }
    return false;
}

int main(void){
    double x1, x2, x3, y1, y2, y3;
    double xp, yp;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
    bool d;
    d = judge(x1, x2, x3, y1, y2, y3, xp, yp);
    if(d){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
double x[4],y[4],r[3];
void che(int a,int b){
	if(x[a]>x[b]){
		swap(x[a],x[b]);
		swap(y[a],y[b]);
	}
}
int main(){
	int m=0;
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3]){
		che(0,1);
		che(1,2);
		che(0,1);
		if(y[0]<=y[3] && y[3]<=y[1]){
			r[0]=x[0]+(x[2]-x[0])*(y[3]-y[0])/(y[2]-y[0]);
			r[1]=x[0]+(x[1]-x[0])*(y[3]-y[0])/(y[1]-y[0]);
			if(r[0]>r[1])swap(r[0],r[1]);
		}else if(y[1]<=y[3] && y[3]<=y[2]){
			r[0]=x[2]+(x[0]-x[2])*(y[2]-y[3])/(y[2]-y[0]);
			r[1]=x[2]+(x[1]-x[2])*(y[2]-y[3])/(y[2]-y[1]);
			if(r[0]>r[1])swap(r[0],r[1]);
		}else{
			cout<<"NO"<<endl;
			continue;
		}
		if(r[0]<=x[3] && x[3]<=r[1]){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define EPS (1e-7)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

//作成中
class Point3d{
public:
  double x,y,z;

  Point3d(double x=0,double y=0,double z=0):x(x),y(y),z(z){}

  Point3d operator + (const Point3d& a){
    return Point3d(x+a.x,y+a.y,z+a.z);
  }
  Point3d operator - (const Point3d& a){
    return Point3d(x-a.x,y-a.y,z-a.z);
  }
  Point3d operator * (const double& d){
    return Point3d(x*d,y*d,z*d);
  }
  Point3d operator / (const double& d){
    return Point3d(x/d,y/d,z/d);
  }

  bool operator < (const Point3d& p)const{
    return !equals(x,p.x)?x<p.x:((!equals(y,p.y))?y<p.y:z<p.z);
  }

  bool operator == (const Point3d& p)const{
    return equals(x,p.x) && equals(y,p.y) && equals(z,p.z);
  }

};

struct Segment3d{
  Point3d p[2];
  Segment3d(Point3d p1=Point3d(),Point3d p2=Point3d()){
    p[0] = p1, p[1] = p2;
  }
  bool operator == (const Segment3d& seg)const{
    return p[0] == seg.p[0] && p[1] == seg.p[1];
  }
};

typedef Point3d Vector3d;
typedef Segment3d Line3d;

ostream& operator << (ostream& os,const Point3d& p){
  os << "(" << p.x << "," << p.y << "," << p.z << ")";
}

ostream& operator << (ostream& os,const Segment3d& seg){
  os << "(" << seg.p[0] << "," << seg.p[1] << ")";
}

double dot(const Point3d& a,const Point3d& b){
  return a.x*b.x + a.y*b.y + a.z*b.z;
}

Vector3d cross(const Point3d& a,const Point3d& b){
  return Vector3d(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

bool point_on_the_triangle3d(Point3d tri1,Point3d tri2,Point3d tri3,Point3d p){
  Vector3d v1 = tri2 - tri1;
  Vector3d v2 = tri3 - tri2;
  Vector3d v3 = tri1 - tri3;
  bool res  = ( cross(v1,p-tri1).z >= 0 ); //線分上にある場合もtrue,　線分上にある場合は駄目とするならば > 0 とすること
  bool res2 = ( cross(v2,p-tri2).z >= 0 );
  bool res3 = ( cross(v3,p-tri3).z >= 0 );
  return res == res2 && res2 == res3;
}

const string Y = "YES", N = "NO";
int main(){
  Point3d tri[3],p;
  while(cin >> tri[0].x >> tri[0].y >> tri[1].x >> tri[1].y >> tri[2].x >> tri[2].y >> p.x >> p.y){
    cout << (point_on_the_triangle3d(tri[0],tri[1],tri[2],p)?Y:N) << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>

using namespace std;

int main(void){
  double x[3], y[3], cx, cy;
  double p[3];
  
  while (scanf("%lf%lf", &x[0], &y[0])){
    scanf("%lf%lf%lf%lf%lf%lf", &x[1], &y[1], &x[2], &y[2], &cx, &cy);
    for (int i=0; i<3; i++){
      int j=(i+1)%3;
      p[i] = (x[i]-cx)*(y[j]-cy)-(x[j]-cx)*(y[i]-cy);
      printf("%lf\n", p[i]);
    }
    puts(p[0]*p[1]<0||p[1]*p[2]<0||p[2]*p[0]<0 ? "NO": "YES");
  }
  return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
double helon(double x1,double y1,double x2,double y2,double x3,double y3){
	double a,b,c,s,area;
	a = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	c = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	s = (a+b+c)/2;
	area = sqrt(s*(s-a)*(s-b)*(s-c));
	return area;
}

int main(){
	double e=0.0000000001;
	double x1,y1,x2,y2,x3,y3,xp,yp;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		double s,s1,s2,s3;
		s = helon(x1,y1,x2,y2,x3,y3);
		s1 = helon(xp,yp,x1,y1,x2,y2);
		s2 = helon(xp,yp,x2,y2,x3,y3);
		s3 = helon(xp,yp,x3,y3,x1,y1);
		cout<<s<<" "<<s1<<" "<<s2<<" "<<s3<<endl;
		if(s1==0 || s2==0 || s3==0)
			cout<<"NO"<<endl;
		else if(fabs(s-(s1+s2+s3))<e)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

bool get_line( double , double , double , double , double& , double& );

int main(void)
{
	double x1, x2, x3, xp;
	double y1, y2, y3, yp;
	double a1, a2, a3, b1, b2, b3;
	bool result1 , result2 , result3;

	int flag1, flag2, flag3;
	int flag1p , flag2p , flag3p;

	while(1)
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
		if( cin.eof() ) break;

		result1 = get_line( x1 , y1 , x2 , y2 , a1 , b1 );
		result2 = get_line( x2 , y2 , x3 , y3 , a2 , b2 );
		result3 = get_line( x3 , y3 , x1 , y1 , a3 , b3 );

		if( result1 == true )
		{
			if( y3 > a1 * x3 + b1 ) flag1 = 1;
			else flag1 = 0;
			if( yp > a1 * xp + b1 ) flag1p = 1;
			else flag1p = 0;
		}
		else
		{
			if( x3 > (x1+x2)/2 ) flag1 = 1;
			else flag1 = 0;
			if( xp > (x1+x2)/2 ) flag1p = 1;
			else flag1p = 0;
		}
		if( result2 == true )
		{
			if( y1 > a2 * x1 + b2 ) flag2 = 1;
			else flag2 = 0;
			if( yp > a2 * xp + b2 ) flag2p = 1;
			else flag2p = 0;

		}
		else
		{
			if( x1 > (x2+x3)/2 ) flag2 = 1;
			else flag2 = 0;
			if( xp > (x2+x3)/2 ) flag2p = 1;
			else flag2p = 0;
		}
		if( result3 == true )
		{
			if( y2 > a3 * x2 + b3 ) flag3 = 1;
			else flag3 = 0;
			if( yp > a3 * xp + b3 ) flag3p = 1;
			else flag3p = 0;
		}
		else
		{
			if( x2 > (x3+x1)/2 ) flag3 = 1;
			else flag3 = 0;
			if( xp > (x3+x1)/2 ) flag3p = 1;
			else flag3p = 0;
		}

		if( flag1 == flag1p && flag2 == flag2p && flag3 == flag3p ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}


	return 0;
}

bool get_line( double x1 , double y1 , double x2 , double y2 , double& a , double& b )
{
	if( x1 - x2 >= -0.0001 && x1 - x2 <= 0.0001 )
	{
		return false;
	}
	else
	{
		a = ( y1 - y2 )/( x1 - x2 );
		b = y1 - a * x1;

		return true;
	}
}