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 <cstdio>
#include <math.h>
using namespace std;

typedef struct P {
	double x, y;
} P;
typedef struct vec {
	double x, y;
	vec() {}
	vec(P p1, P p2) {
		x = p2.x - p1.x;
		y = p2.y - p1.y;
	}
} vec;
inline double cross(vec v1, vec v2) {
	return v1.x*v2.y - v1.y*v2.x;
}

P p[4];
vec v[3];
double a, b;
int ar[3][4] = {
	{0,1,2, },{1,2,0,3},{2,0,1,3}
};

int main(){
	bool f;
	while (true) {
		for (int i = 0; i < 4; i++) {
			if (scanf("%lf%lf", &p[i].x, &p[i].y) == EOF) {
				return 0;
			}
		}
		f = true;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				v[j] = vec(p[ar[i][0]], p[ar[i][j + 1]]);
			}
			a = cross(v[0], v[1]);
			b = cross(v[0], v[2]);
			if (a*b < 0 || fabs(a) - fabs(b) < 0) {
				printf("NO\n");
				f = false;
				break;
			}
		}
		if (f) {
			printf("YES\n");
		}
	}

	return 0;
}

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

float S(float a, float b, float c, float d, float e, float f) {
	float ans;
	ans = abs((a - e) * (d - f) - (b - f) * (c - e));
	return ans;
}

int main(){
	float x[4], y[4], s[3], SS, SSS;

	while(true){
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		if (cin.eof()) { break; }
		s[0] = S(x[0], y[0], x[1], y[1], x[3], y[3]);
		s[1] = S(x[0], y[0], x[2], y[2], x[3], y[3]);
		s[2] = S(x[1], y[1], x[2], y[2], x[3], y[3]);
		if(s[0] * s[1] * s[2] == 0){ 
			cout << "NO" << endl;
			continue;
		}
		SS = s[0] + s[1] + s[2];
		SSS = S(x[0], y[0], x[1], y[1], x[2], y[2]);

		if (SS == SSS) { cout << "YES" << endl; }
		else { cout << "NO" << endl; }
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <complex>
#define print(a) cout << a << endl;
using namespace std;
typedef complex<double> P;

//三角形の内部にあるか
bool is_in_triangle(double cross1, double cross2, double cross3) {
    return((cross1 > 0 && cross2 > 0 && cross3 > 0) || (cross1 < 0 && cross2 < 0 && cross3 < 0));
}
//ベクトルの引き算
P subVector(P a, P b) {
    return(P(a.real() - b.real(), a.imag() - b.imag()));
}

int main(void) {
    double x1, y1, x2, y2, x3, y3, px, py;
    
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &px, &py) != EOF) {
        P a(x1, y1), b(x2, y2), c(x3, y3), p(px, py);
        //辺ベクトル、頂点と辺とのベクトル
        P ab = subVector(b, a), bc = subVector(c, b), ca = subVector(a, c);
        P bp = subVector(p, b), cp = subVector(p, c), ap = subVector(p, a);
        //外積(z成分のみ)
        double cross1 = ab.real() * bp.imag() - ab.imag() * bp.real(),
               cross2 = bc.real() * cp.imag() - bc.imag() * cp.real(),
               cross3 = ca.real() * ap.imag() - ca.imag() * ap.real();
        //判定
        if(is_in_triangle(cross1, cross2, cross3)) cout << "YES" << endl;
        else                                       cout << "NO"  << endl;
    }
    return(0);
}

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

using namespace std;

bool checker(double a, double b,double x, double y, double px, double py, bool f);

double calc_slope(double x1, double y1, double x2, double y2);

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  double a1, a2, a3, b1, b2, b3;
  vector<double> x1s,y1s,x2s,y2s,x3s,y3s,xps,yps;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    x1s.push_back(x1);
    y1s.push_back(y1);
    x2s.push_back(x2);
    y2s.push_back(y2);
    x3s.push_back(x3);
    y3s.push_back(y3);
    xps.push_back(xp);
    yps.push_back(yp);
  }

  for(int i=0; i<x2s.size(); i++){
    bool flag = true, f;
    x1 = x1s[i];
    y1 = y1s[i];
    x2 = x2s[i];
    y2 = y2s[i];
    x3 = x3s[i];
    y3 = y3s[i];
    xp = xps[i];
    yp = yps[i];


    a1 = calc_slope(x1,y1,x2,y2);
    if(a1==0 && y1==y2){
      b1 = y1;
      f = false;
    }else if(a1==0 && x1==x2){
      b1 = x1;
      f = true;
    }else{
      b1 = -a1*x1+y1;
    }
    flag &= checker(a1,b1,x3,y3,xp,yp,f);

    a2 = calc_slope(x2,y2,x3,y3);
    if(a2==0&&y2==y3){
      b2 = y2;
      f = false;
    }else if(a2==0&&x2==x3){
      b2 = x2;
      f = true;
    }else{
      b2 = -a2*x2+y2;
    }
    flag &= checker(a2,b2,x1,y1,xp,yp,f);

    a3 = calc_slope(x3,y3,x1,y1);
    if(a3==0&&y3==y1){
      b3 = y3;
      f = false;
    }else if(a3==0&&x3==x1){
      b3 = x3;
      f = true;
    }else{
      b3 = -a3*x3+y3;
    }
    flag &= checker(a3,b3,x2,y2,xp,yp,f);

    if(flag){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

bool checker(double a, double b, double ox, double oy, double px, double py, bool flag){
  if(a == 0 && flag){
    if(b < ox && b < px){
      return true;
    }
    else if(b > ox && b > px){
      return true;
    }else{
      return false;
    }
  }else if(a==0){
    if(b < oy && b < py){
      return true;
    }
    else if(b > oy && b > py){
      return true;
    }else{
      return false;
    }
  }

  if(oy < a*ox+b && py < a*px+b){
    return true;
  }
  else if(oy > a*ox+b && py > a*px+b){
    return true;
  }
  else{
    return false;
  }
}

double calc_slope(double x1, double y1, double x2, double y2){
  if(x1 > x2){
    return (y1-y2)/(x1-x2);
  }else if(x1 < x2){
    return (y2-y1)/(x2-x1);
  }else{
    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) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;
static const double eps = 1e-8;

double x[3],y[3];
double xp,yp;

double dist(P a,P b){
	return (sqrt((real(a)-real(b))*(real(a)-real(b))+(imag(a)-imag(b))*(imag(a)-imag(b))));
}

double tri_pro(P a,P b,P c){
	double aa,bb,cc;
	aa = dist(b,c);
	bb = dist(c,a);
	cc = dist(a,b);
	double s = (aa+bb+cc)/2.0;
	return sqrt(s*(s-aa)*(s-bb)*(s-cc));
}


int main(){
	while(cin>>x[0]>>y[0]){
		rep(i,2) cin>>x[i+1]>>y[i+1];
		cin>>xp>>yp;
		P a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]);
		P p(xp,yp);
		double sa,sb,sc;
		sa = tri_pro(b,c,p);
		sb = tri_pro(c,a,p);
		sc = tri_pro(a,b,p);
		double s = tri_pro(a,b,c);
		cout<<"s="<<s<<"\nsa sb sc "<<sa<<" "<<sb<<" "<<sc<<endl;
		if(s-(sa+sb+sc)<eps) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

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

int main(void) {
	double x[4], y[4];
	double xp, yp;

	while(!cin.eof()) {
		bool l, r;
		l = r = false;
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp;
		x[3] = x[0];
		y[3] = y[0];

		for(int i = 0; i < 3; i++) {
			double ax = x[i+1] - x[i];
			double ay = y[i+1] - y[i];
			double px = xp - x[i];
			double py = yp - x[i];
			if(ax*py - ay*px < 0)
				r = true;
			else
				l = true;
		}
		cout << (r ^ l ? "YES" : "NO") << endl;
	}
	return 0;
}