Go: package main

import "fmt"

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var x1, y1, x2, y2, x3, y3, x4, y4 float64
	fmt.Scan(&n)
	for i := 0 ; i < n; i++ {
		fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)
		if abs((x2-x1)*(y4-y3) - (y2-y1)*(x4-x3)) < 1e-10 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
 
using namespace std;
 
double EPS = 1e-10;
const double PI = acos(-1);
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){x=y=0;}
  point(double x,double y) : x(x) , y(y){}
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
};
 
double cross(point a, point b) {return (a.x * b.y - a.y * b.x);}
 
int is_parallel(point a1, point a2, point b1, point b2) {
  return cross(a1-a2, b1-b2)==0.0 ;
}
 
int main(void){
 
  point a,b,c,d;
  int n;
  cin >> n;
 
  while(n--){
    cin >> a.x >> a.y >> b.x >> b.y;
    cin >> c.x >> c.y >> d.x >> d.y;
    if(is_parallel(a,b,c,d))cout << "YES" << endl;
    else cout << "NO" << endl;
  }
 
  return 0;
}

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

typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
const double eps = 1e-11;
double x[4],y[4];
int N;
int main() {
	cin >> N;
	for (int i=0; i<N; ++i) {
		for (int i=0; i<4; ++i) {
			cin >> x[i] >> y[i];
		}
		xy_t a[2] = {
					xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
					xy_t(x[2],y[2]) - xy_t(x[3],y[3])
				};
		bool p = abs(cross_product(a[0],a[1]))/2 < eps;
		cout << ( p ? "YES" : "NO") << endl;
	}
}

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

double EPS = 1e-8;

//??\????????°???????????°?????????????????????
//????¬?????????????????????????
//??¢??°vAdd, vSet????????????????????????????????¢?????????????????¶public:
//???????????????????????°??????????????§????????¨?????¶
//??\???????????§??????????????????????????????????????????????????????
class C3DVec{
    private:    //private: ????????¨???????????¢??????????????§?????????
    
    public:     //public: ????????¨???????????¢???????????????
    double x, y;
    
    //??°????????????????????????+????????????????????????
    C3DVec operator+(C3DVec v2){
        C3DVec vRet;
        
        //???????????????v?????¨??????
        vRet.x = x + v2.x;
        vRet.y = y + v2.y;
    
        return vRet;
    }
    
    //????§???????????????????????????????
    C3DVec operator-(C3DVec v2){
        C3DVec vRet;
        
        //???????????????v1??¨??????
        vRet.x = x - v2.x;
        vRet.y = y - v2.y;
        
        return vRet;
    }
    
    //????§?????????????????????¨??????????????????????????????
    C3DVec operator*(float sc){
        C3DVec vRet;
        
        vRet.x = x * sc;
        vRet.y = y * sc;
        
        return vRet;
    }
    
    
    
    //()????????????????????????????????°????????????????????±??????
     void operator() (double ix, double iy){
        C3DVec vRet;
    
        x = ix;
        y = iy;
    }
};

//???????????¨?????\??????????????????????????????????????????????????????????????¢??°
C3DVec operator*(float sc, C3DVec vi){
    C3DVec vRet;
    
    //?????????????????????????????????????????°????????????????????§???
    //??¢??°??????????????????????????????????????????
    vRet.x = vi.x * sc;
    vRet.y = vi.y * sc;
    
    return vRet;
}

//????????????????????????????????????
    double dot(C3DVec v1, C3DVec v2){
        return (v1.x * v2.x) + (v1.y * v2.y);
    }


int main(void){
    C3DVec va, vb, vc, vd;
    double x1, x2, x3, x4, y1, y2, y3, y4;
    int n;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        //??????????????????
        cin >> x1 >> y1 >> x2 >> y2;
        cin >> x3 >> y3 >> x4 >> y4;
        
        //?????????????????????
        va(x1, y1);
        vb(x2, y2);
        vc(x3, y3);
        vd(x4, y4);
        
        //????????????????????????
        C3DVec vAB = vb - va;
        C3DVec vCD = vd - vc;
         
        //???????????¶????????????????????????
        if(dot(vAB, vCD) < EPS) cout << "YES" << endl;
        else            cout << "NO"  << endl;; 
    }
    
    return 0;
}

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

int main()
{
	int n;
	double x[4], y[4];
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++){
			cin >> x[j] >> y[j];
		}

		double l1, l2;
		l1 = (y[0] - y[1]) / (x[0] - x[1]);
		l2 = (y[2] - y[3]) / (x[2] - x[3]);
		if (l1 == l2){
			cout << "YES" << endl;
		}

		else {
			cout << "NO" << endl;
		}
	}
	return (0);
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

typedef std::pair<double,double> Vec;
typedef std::pair<Vec,Vec> Line;

Vec operator+(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first+rhs.first, lhs.second+rhs.second);
}

Vec operator-(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first-rhs.first, lhs.second-rhs.second);
}

Vec lineToVec(const Line& l) {
	return l.first - l.second;
}

double cross(const Vec& lhs, const Vec& rhs) {
  return lhs.first*rhs.second - lhs.second*rhs.first;
}

int main(void){
	using namespace std;

	int n;
	cin >> n;

	vector< pair<Line,Line> > input;
	input.reserve(n);

	for(int i=1; i<=n; i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		cin
			>> x1 >> y1
			>> x2 >> y2
			>> x3 >> y3
			>> x4 >> y4;

		auto AB = make_pair( make_pair(x1,y1), make_pair(x2,y2) );
		auto CD = make_pair( make_pair(x3,y3), make_pair(x4,y4) );

		input.push_back(make_pair(AB,CD));
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		auto AB = itr->first;
		auto CD = itr->second;

		auto cr = cross( lineToVec(AB), lineToVec(CD) );

		if( abs(cr) <10e-300 ){
			cout << "YES";
		}
		else{
			cout << "NO";
		}
		if( distance( itr, input.end() )>1 ){
			cout << endl;
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<string>
//#define nINF -2147483648
using namespace std;
/*
int p10(int x)  //10^x
{
	int d141771=1; for (int i=1;i<=x;i++) d141771*=10; return d141771;
}
*/
int main()
{
	double x1,y1,x2,y2,x3,y3,x4,y4,k1,k2,z1,z2,z3,z4;
	int n;
	cin>>n;
	bool up1,up2;
	for (int k=1;k<=n;k++)
	{
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		k1=0; k2=0;
		up1=false; up2=false;
		z1=y1-y2; z2=x1-x2;
		z3=y3-y4; z4=x3-x4;
		if (z2==0) up1=true;
		if (z4==0) up2=true;
		if (z2!=0) k1=z1/z2;
		if (z4!=0) k2=z3/z4;
		if (z2!=0&&z4!=0)
		{
			if (k1==k2) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else
		{
			if (k1==k2&&up1==up2) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int k;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double veku1[2];
	double veku2[2];
	double veku3[2];
	double t;
	double m;
	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		veku1[0] = x2 - x1;
		veku1[1] = y2 - y1;
		veku2[0] = x4 - x3;
		veku2[1] = y4 - y3;
		if (((veku1[0] * veku2[1]) - (veku1[1] * veku2[0])) == 0) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}