Go: package main

import (
        "fmt"
)

func main() {
        var x1, y1, x2, y2, x3, y3, px, py float64
        var oax, oay, obx, oby, opx, opy float64
        var det float64
        var s, t float64

        for {
                _, err := fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &px, &py)
                if err != nil {
                        break
                }
                oax = x2 - x1
                oay = y2 - y1
                obx = x3 - x1
                oby = y3 - y1
                opx = px - x1
                opy = py - y1
                det = oax*oby - obx*oay

                if det == 0 {
                        fmt.Printf("NO\n")
                } else {
                        s = (oby*opx - obx*opy) / det
                        t = (oax*opy - oay*opx) / det

                        if (s+t < 1 && s > 0 && t > 0) {
                                fmt.Printf("YES\n")
                        } else {
                                fmt.Printf("NO\n")
                        }
                }
        }
}

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

using namespace std;

struct Vector{
  double x,y;
  Vector operator-(const Vector &v)const{
    return Vector(x-v.x,y-v.y);
  }
  Vector():x(0),y(0){}
  Vector(const Vector &v):x(v.x),y(v.y){}
  Vector(double xx,double yy):x(xx),y(yy){}
  Vector& operator=(const Vector& v){
    x=v.x;
    y=v.y;
    return (*this);
  }
};

struct Triangle{
  Vector v[3];
};

double outerprod(const Vector &v1,const Vector &v2);
bool is_in(const Triangle&,const Vector&);
int main(){
  Vector v;
  Triangle t;
  while(std::cin>>t.v[0].x>>t.v[0].y>>t.v[1].x>>t.v[1].y>>t.v[2].x>>t.v[2].y>>v.x>>v.y){
     if(is_in(t,v)){
       std::cout<<"YES"<<std::endl;
     }else{
       std::cout<<"NO"<<std::endl;
     }
  }
  return 0;
}

double outerprod(const Vector &v1,const Vector &v2){
  return v1.x*v2.y-v2.x*v1.y;
}

bool is_in(const Triangle& t,const Vector& v){
  double prod1 = outerprod(t.v[1]-t.v[0],v-t.v[1]);
  double prod2 = outerprod(t.v[2]-t.v[1],v-t.v[2]);
  double prod3 = outerprod(t.v[0]-t.v[2],v-t.v[0]);
  return (prod1<0&&prod2<0&&prod3<0)||(prod1>0&&prod2>0&&prod3>0);
}

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

int check( double x0, double y0, double x1, double y1, double x2, double y2 ){
	return (x1-x0)*(y2-y0)-(y1-y0)*(x2-x0) > 0 ? 1 : -1; 
}

int main(){
	double x[3], y[3], xp, yp;
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&xp,&yp) != EOF ){
		int ch = check( x[0], y[0], x[1], y[1], xp, yp );
		ch += check( x[1], y[1], x[2], y[2], xp, yp );
		ch += check( x[2], y[2], x[0], y[0], xp, yp );
		if( ch==3 || ch==-3 ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){

    double x[4],y[4];
    while(true){
	REP(i,4) {
	    cin >> x[i];
	    if(cin.eof()) return 0;
	    cin >> y[i];
	}
	double s,t;
	double m = 0;
	bool flg = false;
	REP(i,1e6){
	    s = ((double)i/1e6);
	    t = (double)1 - s;
	    double x1 = s * (x[2] - x[0]) + t * ( x[1] - x[0]);
	    double y1 = s * (y[2] - y[0]) + t * ( y[1] - y[0]);
	    double x2 = x[3] - x[0];
	    double y2 = y[3] - y[0];
	    double dotpro =  (  (x1 * x2 + y1 * y2 )*(x1 * x2 + y1 * y2 ) )  /( (x1*x1 + y1*y1)*(x2*x2 + y2*y2)) ;

        if( (x2 * x2 + y2 * y2) >= (x1*x1 + y1 * y1)) continue;
	    if(  abs(1 - sqrt(dotpro))  <= 1e-3  ){
	
		    flg = true;
		    break;
	    }
	}
	if(flg) cout << "YES" << endl;
	else cout << "NO" << endl;

    }

    return 0;
}

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

int sign(double n){
	if(n < 0)return -1;
	else if(n > 0)return 1;
	return 0;
}

double angle(double ax, double ay, double bx, double by, double cx, double cy){
    //angle between ab and ac
    double ab = atan2(by-ay,bx-ax);
    double ac = atan2(cy-ay,cx-ax);
    if(ab < 0)ab += 2*M_PI;
    if(ac < 0)ac += 2*M_PI;
    double ang = ac - ab;
    return (fabs(ang) < M_PI ? ang : -sign(ang) * 2 * M_PI + ang) * 180 / M_PI;
}

bool isPointInPolygon(complex< double > a, vector< complex< double > > p){
	int n = p.size();
	double sum = 0;
	
	for(int i = 0; i < n; ++i){
		sum += angle(a.real(), a.imag(), p[i].real(), p[i].imag(), p[(i+1)%n].real(), p[(i+1)%n].imag());
	}
	
	if(abs(sum) >= 300){ //if sum is 360
		return true;
	}
	return false; //if sum is 0
}

int main(){
	double x1, y1, x2, y2, x3, y3 , xp, yp;
	vector< complex< double > > triangle;
	complex< double > point;
	
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		point = complex< double >(xp, yp);
		triangle.push_back(complex< double >(x1, y1));
		triangle.push_back(complex< double >(x2, y2));
		triangle.push_back(complex< double >(x3, y3));
		
		if(isPointInPolygon(point, triangle))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

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

int main(){
	double x1,y1,x2,y2,x3,y3,xp,yp;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;

	while(!cin.eof()){
		int sign1=(((x2-x1)*(yp-y1)-(xp-x1)*(y2-y1))>0)?1:0;
		int sign2=(((x3-x2)*(yp-y2)-(xp-x2)*(y3-y2))>0)?1:0;
		int sign3=(((x1-x3)*(yp-y3)-(xp-x3)*(y1-y3))>0)?1:0;
		//cout << sign1 << sign2 << sign3;
		if(sign1==sign2 && sign2==sign3)
			cout << "YES\n";
		else
			cout << "NO\n";

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;

	}
}

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

using namespace std;

double distance(double x1, double y1, double x2, double y2)
{
	return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

double helon(double a, double b, double c)
{
	double s = (a + b + c) / 2;

	return sqrt(s * (s - a) * (s - b) * (s - c));
}

double helon(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double a = distance(x1, y1, x2, y2);
	double b = distance(x2, y2, x3, y3);
	double c = distance(x3, y3, x1, y1);

	return helon(a, b, c);
}

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while ( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		if (round(helon(x1, y1, x2, y2, x3, y3)*100) == round((helon(x1, y1, x2, y2, xp, yp) + helon(x2, y2, x3, y3, xp, yp) + helon(x3, y3, x1, y1, xp, yp)) *100)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

int main() {
    P a,b,c,d;
    while(cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y >> d.X >> d.Y) {
        int x = ccw(a,b,d);
        int y = ccw(b,c,d);
        int z = ccw(c,a,d);
        printf("%d %d %d\n", x, y, z);
        if(x == 1 && y == 1 && z == 1) cout << "YES" << endl;
        else if(x == -1 && y == -1 && z == -1) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}