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 <cmath>

double x[4],y[4];

struct vektor{
	double x,y;
	vektor(){}
	vektor(double xx,double yy){
		x=xx;
		y=yy;
	}
};

vektor vek[3];

vektor make_vektor(int i,int j){
	return vektor(x[j]-x[i],y[j]-y[i]);
}

bool check(){
	double s=-(vek[2].x*vek[1].y-vek[2].y*vek[1].x)/(vek[1].x*vek[0].y-vek[1].y*vek[0].x);
	double t=(vek[2].x*vek[0].y-vek[2].y*vek[0].x)/(vek[1].x*vek[0].y-vek[1].y*vek[0].x);
	//printf("%.3f %.3f\n",s,t);
	if(s>0 && t>0 && s+t<1)return true;
	return false;
}

int main(void){
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])){
		for(int i=0;i<3;i++){
			vek[i]=make_vektor(0,i+1);
		}
		printf("%s\n",check()?"YES":"NO");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
    double x1,y1,x2,y2,x3,y3,x,y,a,b,c;
    while(cin >> x1 >> y1 >> x2 >> y2>> x3 >> y3 >> x >> y){
        a=((y-y2)*(x-x1)-(y-y1)*(x-x2))*((y3-y2)*(x3-x1)-(y3-y1)*(x3-x2));
        b=((y-y3)*(x-x2)-(y-y2)*(x-x3))*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3));
        c=((y-y3)*(x-x1)-(y-y1)*(x-x3))*((y2-y3)*(x2-x1)-(y2-y1)*(x2-x3));
        if(a>0 && b>0 && c>0)   cout << "YES" << endl;
        else                    cout << "NO" <<endl;
    }
}

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

const int INF = 1e9 + 10;

const double eps = 1e-11;
double cross_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).imag();
}

int main() {
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    complex<double> a = {x1, y1}, b = {x2, y2}, c = {x3, y3}, p = {xp, yp};
    double t1 = cross_product(b - a, p - a);
    double t2 = cross_product(c - b, p - b);
    double t3 = cross_product(a - c, p - c);
    bool sign = (t1 > 0);
    if (sign == (t2 > 0) && sign == (t3 > 0) && t1 && t2 && t3) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}

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

int main(){
  double x1,y1,x2,y2,x3,y3,px,py;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>px>>py){
    double s1=0,s2=0,s3=0,s=0,a=0,b=0,c=0,a1=0,b1=0,c1=0,a2=0,b2=0,c2=0,a3=0,b3=0,c3=0;
    a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s=(a+b+c)/2;
    s=sqrt(s*(s-a)*(s-b)*(s-c));

    a1=sqrt((px-x2)*(px-x2)+(py-y2)*(py-y2));
    b1=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    c1=sqrt((x3-px)*(x3-px)+(y3-py)*(y3-py));
    s1=(a1+b1+c1)/2;
    s1=sqrt(s1*(s1-a1)*(s1-b1)*(s1-c1));

    a2=sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));
    b2=sqrt((px-x3)*(px-x3)+(py-y3)*(py-y3));
    c2=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s2=(a2+b2+c2)/2;
    s2=sqrt(s2*(s2-a2)*(s2-b2)*(s2-c2));

    a3=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    b3=sqrt((x2-px)*(x2-px)+(y2-py)*(y2-py));
    c3=sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
    s3=(a3+b3+c3)/2;
    s3=sqrt(s3*(s3-a3)*(s3-b3)*(s3-c3));

    if((-N<s1 && s1<N) || (-N<s2 && s2<N) || (-N<s3 && s3<N) )cout<<"NO"<<endl;
    else if((s1+s2+s3)>s-N && (s1+s2+s3)<s+N )cout<<"YES"<<endl;
    else  cout<<"NO"<<endl; 
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

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

double cross(int a, int b){
    return x[a] * y[b] - y[a] * x[b];
}

signed main(){
    while(1){
        rep(i, 0, 3) cin >> x[i] >> y[i];
        cin >> xp >> yp;
        if(cin.eof()) break;        
        
        rep(i, 0, 3){
            x[i] -= xp;
            y[i] -= yp;
        }
        int cnt = 0;
        rep(i, 0, 3){
            if(cross(i, (i + 1) % 3) < 0) cnt++;
        }
        cout << (cnt % 3 == 0 ? "YES" : "NO") << endl;
    }
}

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

using namespace std;

struct P{
    P(double a, double b){
	x = a;
	y = b;
    }
    double x, y;
    double det(P a){
	return x * a.y - y * a.x;
    }
    P operator-(P a){
	return P(x - a.x, y - a.y);
    }
};

int main(){
    double x1, x2, x3, xp, y1, y2, y3, yp;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
	P a = P(x1, y1);
	P b = P(x2, y2);
	P c = P(x3, y3);
	P p = P(xp, yp);
	if(((a - p).det(b - a) <= 0) == ((b - p).det(c - b) <= 0) &&
	   ((b - p).det(c - b) <= 0) == ((c - p).det(a - c) <= 0)) {
	    cout << "YES" << endl;
	}
	else{
	    cout << "NO" << endl;
	}
				
    }
    return 0;
}

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

int gaiseki(double,double,double,double,double,double);

int main() {
	double x[4],y[4];
	int n[3],ans;
	
	for ( int i = 0; i < 4; i++ ) {
		cin >> x[i] >> y[i];
	}
	//三角形の各辺の外積(求めたい点と始点、求めたい点と終点との外積)を取り、全て右か左だったら中に含まれる
	for ( int i = 0; i < 2; i++ ) 
		n[i] = gaiseki(x[i],y[i],x[i + 1],y[i + 1],x[3],y[3]);
	n[2] = gaiseki(x[2],y[2],x[0],y[0],x[3],y[3]);
	
	ans = 0;
	for ( int i = 0; i < 3; i++ )
		ans += n[i];
	
	if ( ans == 3 || ans == -3 )
		cout << "YES" << endl;
	cout << "NO" << endl;
	
	return 0;
}

int gaiseki(double x1,double y1,double x2,double y2,double xp,double yp) {
	double ans;
	ans =  xp * ( y1 - y2 ) + x1 * ( y2 - yp ) + x2 * ( yp - y1 );
	if ( ans > 0 ) return 1; //右側
	else return 0; //左側(＝だと線上だが、今回は考えなくて良い)
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
double x[4],y[4],r[3];
void che(a,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;
}