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 <bits/stdc++.h>
#include <complex>
#include <cmath>
#include <iostream>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;
typedef complex<double> xy_t;

double cross_product(xy_t a,xy_t b){
	return (conj(a)*b).imag();
}

double x[4],y[4];

int main(){
	while(true){
		rep(i,0,4) cin>>x[i]>>y[i];
		if(!cin) break;
		xy_t a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]),p(x[3],y[3]);
		int pab,pbc,pca;
		bool ok=0;
		pab=cross_product(a-p,b-p);
		pbc=cross_product(b-p,c-p);
		pca=cross_product(c-p,a-p);
		if((pab>0 && pbc>0 && pca>0)||(pab<0 && pbc<0 && pca<0)) ok=1;
		cout<<(ok?"YES":"NO")<<endl;
	}
}

C++: #include<iostream>
using namespace std;
struct vect{
  double x,y;
};
double Sc(vect a,vect b,vect c){
  double S;
  b.x = b.x - a.x;
  b.y = b.y - a.y;
  c.x = c.x - a.x;
  c.y = c.y - a.y;
  S = b.x * c.y - b.y * c.x;
  if(S >= 0){
    return S/2;} else if(S < 0){
    return -S/2;
  }
}

int main(){
  vect a,b,c,p;
  int n;
  cin >> n;
  
  while(cin >> a.x >> a.y  >> b.x >> b.y >>c.x >>c.y >> p.x >> p.y){
   if(Sc(a,b,p) == 0 || Sc(a,p,c)== 0|| Sc(p,b,c)==0 ){
     cout << "NO"<< endl;    } else  if(Sc(a,b,p) +Sc(a,p,c) +Sc(p,b,c) == Sc (a,b,c)){    cout << "YES" << endl;
    }else {cout << "NO" << endl;}
    
  }
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>

using namespace std;

typedef complex<double> P;

double dot(P p1,P p2){
	return p1.real() * p2.imag() - p1.imag() * p2.real();
}


int main(){

	double x1,x2,x3,y1,y2,y3;
	double xp,yp;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		P  p1(x1,y1),p2(x2,y2),p3(x3,y3),po(xp,yp);
		bool f = true;
		if( dot(p2-p1,p3-p1) * dot(p2-p1,po-p1) < 0)
			f = false;
		else if(dot(p3-p1,p2-p1) * dot(p3-p1,po-p1) < 0)
			f = false;
		else if(dot(p2-p3,p1-p3) * dot(p2-p3,po-p3) < 0)
			f = false;

		cout << (f ? "YES" : "NO") << endl;

	}

	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;
	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))); 
	    //cout << dotpro << endl;
	    if(  1 - dotpro  <= 1e-3  ){
		    flg = true;
		    break;
	    }
	}
	if(flg) cout << "YES" << endl;
	else cout << "NO" << endl;

    }

    return 0;
}

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

double xa, ya, xb, yb, xc, yc, xp, yp, x, y, z;
double m(double a, double b, double c, double d) {
	return a*d - b*c;
}
int main() {
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa, &ya, &xb, &yb, &xc, &yc, &xp, &yp) != EOF) {
		x = m(xp-xa, yp-ya, xb-xa, yb-ya);
		y = m(xp-xb, yp-yb, xc-xb, yc-yb);
		z = m(xp-xc, yp-yc, xa-xc, ya-yc);
		if ((x<0 && y<0 && z<0) || (x>0 && y>0 && z>0)) printf("YES\n");
		else printf("NO\n");
	}
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define NITENKAN(a, b) sqrt(((a.first - b.first) * (a.first - b.first)) + ((a.second - b.second) * (a.second - b.second)))
using namespace std;

bool checkTriIn(pair<double, double> vA, pair<double, double> vB, pair<double, double> vC, pair<double, double> P){
	pair<double, double> center((vA.first + vB.first + vC.first / 3), (vA.second + vB.second + vC.second / 3));

	vector<pair<double, double> > triangleLine;
	vector<pair<double, double> > centerToVertex;
	pair<double, double> vAvB(vB.first - vA.first, vB.second - vA.second);
	pair<double, double> vBvC(vC.first - vB.first, vC.second - vB.second);
	pair<double, double> vCvA(vA.first - vC.first, vA.second - vC.second);

	triangleLine.push_back(vAvB);
	triangleLine.push_back(vBvC);
	triangleLine.push_back(vCvA);

	pair<double, double> centerP(P.first - center.first, P.second - center.second);
	pair<double, double> centerA(vA.first - center.first, vA.second - center.second);
	pair<double, double> centerB(vB.first - center.first, vB.second - center.second);
	pair<double, double> centerC(vC.first - center.first, vC.second - center.second);

	centerToVertex.push_back(centerA);
	centerToVertex.push_back(centerB);
	centerToVertex.push_back(centerC);

	for(int i = 0; i < 3; i++){
		double cross = triangleLine[i].first * centerP.second - centerP.first * triangleLine[i].second;
		if(cross == 0) continue;
		double r = triangleLine[i].first * centerToVertex[i].second - centerToVertex[i].first * triangleLine[i].second;
		r /= cross;
		double s = centerP.first * centerToVertex[i].second - centerToVertex[i].first * centerP.second;
		s /= cross;

		if(r >= 0 && r <= 1 && s >= 0 && s <= 1){
			return true;
		}
	}
	return false;
}

int main(){
	pair<double, double> vA, vB, vC, P;

	while(cin >> vA.first >> vA.second >> vB.first >> vB.second >> vC.first >> vC.second >> P.first >> P.second){
		if(checkTriIn(vA, vB, vC, P)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

C++: #include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
signed main(void){
    double x[4],y[4],x0,y0;
    while(cin>>x[0]>>y[0]){
    for(int i=1;i<3;i++)
        cin>>x[i]>>y[i];
    cin>>x0>>y0;
    x[3]=x[0],y[3]=y[0];
    int l=0,r=0;
    for(int i=0;i<3;i++){
        double ax=x[i+1]-x[i],ay=y[i+1]-y[i];
        double px=x[i]-x0,py=y[i]-y0;
        if(ax*py-ay*px<0)
            r=1;
        else
            l=1;
    }
    cout<<(l!=r ? "YES" : "NO")<<endl;
	}
    return 0;
}

C++: #include<iostream>
using namespace std;
class Vector {
public:
  double x;
  double y;
  Vector(double xx=0,double yy=0) {x=xx;y=yy;}
  Vector operator+(Vector p) ;
  Vector operator-(Vector p);
};
Vector Vector::operator+(Vector p) {
  Vector tmp;
  tmp.x=x+p.x;
  tmp.y=y+p.y;
  return tmp;
}
Vector Vector::operator-(Vector p) {
  Vector tmp;
  tmp.x=x+p.x;
  tmp.y=y+p.y;
  return tmp;
}
bool check_hit(Vector A,Vector B,Vector C,Vector P);

int main() {
  double x1,x2,x3,y1,y2,y3,x,y;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x>>y) {
    Vector A(x1,y1);
    Vector B(x2,y2);
    Vector C(x3,y3);
    Vector P(x,y);
    if(check_hit(A,B,C,P))
      cout<<"YES\n";
    else
      cout<<"NO\n"; 
   }
  return 0;
}
bool check_hit(Vector A,Vector B,Vector C,Vector P) {
  Vector AB=B-A;
  Vector BC=C-B;
  Vector CA=A-C;
  Vector AP=P-A;
  Vector BP=P-B;
  Vector CP=P-C;
  double calc1=AB.x*BP.y - AB.y*BP.x;
  double calc2=BC.x*CP.y - BC.y*CP.x;
  double calc3=CA.x*AP.y - CA.y*AP.x;
  if( (calc1>0 && calc2>0 && calc3>0)||(calc1<0 && calc2<0 && calc3<0) )
    return false;
  return true;
      }