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 <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define range(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) range(i, 0, n)
const ll INF = 1e10;
#define pb push_back

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        vector<double> x(4), y(4);
        rep(j, 4) cin >> x[j] >> y[j];
        double a = (x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2]);
        cout << a << endl;
        if (a != 0) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}

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

using namespace std;

struct point {
	double x, y;
};

struct segLine {
	point s, e;	
}segA, segB;

int main() {
	int t;
	scanf ("%d", &t);
	while (t--) {
		scanf ("%lf%lf%lf%lf", &segA.s.x, &segA.s.y, &segA.e.x, &segA.e.y);
		scanf ("%lf%lf%lf%lf", &segB.s.x, &segB.s.y, &segB.e.x, &segB.e.y);
		if ((segA.e.y-segA.s.y)*(segB.e.x-segB.s.x)==(segB.e.y-segB.s.y)*(segA.e.x-segA.s.x))  printf ("YES\n");
		else printf ("NO\n");
	}
	return 0; 
}

C++: #include <iostream>
 
using namespace std;
 
 
 
struct pt {
 
    double x;
 
    double y;
 
};
 
 
 
int main() {
 
    int num;
 
    cin >> num;
 
    while(num--) {
 
        pt p1, p2, p3, p4;
 
        cin >> p1.x >> p1.y;
 
        cin >> p2.x >> p2.y;
 
        cin >> p3.x >> p3.y;
 
        cin >> p4.x >> p4.y;
 
        pt v1 = {p1.x-p2.x, p1.y-p2.y};
 
        pt v2 = {p3.x-p4.x, p3.y-p4.y};
 
        if (v1.y==0 && v2.y==0) cout << "YES\n";
 
        else if (v1.x/v1.y == v2.x/v2.y) cout << "YES\n";
 
        else cout << "NO\n";
 
    }
 
    return 0;
 
}

C++: #include <iostream>
 
using namespace std;
 
int main() {
    double x1,x2,x3,x4;
    double y1,y2,y3,y4;
    double incAB, incCD;
    int count=0;
    cin>>count;
    for(int i=0; i<count; i++) {
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        incAB = (y2-y1) / (x2-x1);
        incCD = (y4-y3) / (x4-x3);
        if(incAB == incCD) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #!/usr/bin/python
# -*- coding:utf-8 -*-

def main():
	numData = int(raw_input())
	count = 0
	while count < numData:
		line = raw_input()
		coords = map(float, line.strip().split())
		result = isParallel(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7])

		if result :
			print "YES"
		else:
			print "NO"

		count += 1

def isParallel(x1, y1, x2, y2, x3, y3, x4, y4):
	# 小数点以下最大５桁までの精度で計算すればよい
	x1 = int(x1 * 100000)
	y1 = int(y1 * 100000)
	x2 = int(x2 * 100000)
	y2 = int(y2 * 100000)
	x3 = int(x3 * 100000)
	y3 = int(y3 * 100000)
	x4 = int(x4 * 100000)
	y4 = int(y4 * 100000)
	# 直線ABの傾きが無限大かどうか
	if (x2 == x1):
		# 傾き無限大ならば、CDもそうなら平行
		return x4 == x3
	else:
		# 有限の傾きならば傾きが等しければOK
		return (y2 - y1)/(x2 - x1) == (y4 - y3)/(x4 - x3)

main()

C++: //
//  main.cpp
//  main
//
//  Created by h3037175 on 2018/01/22.
//  Copyright © 2018年 h3037175. All rights reserved.
//

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
double zeti(double);
int main() {
    pair<double,double> a;
    pair<double,double> b;
    pair<double,double>c;
    pair<double,double>d;
    int n;
    double s1,s2;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a.first>>a.second>>b.first>>b.second>>c.first>>c.second>>d.first>>d.second;
        if((a.first==b.first&&c.first==d.first) || (a.second==b.second&&c.second==d.second)){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a.first==b.first||c.first==d.first||a.second==b.second || c.second == d.second){
            cout<<"NO"<<endl;
            continue;
        }
        s1=(a.second-b.second)/(a.first-b.first);
        s2=(c.second-d.second)/(c.first-d.first);
        cout<<s1<<" "<<s2<<endl;
        if(s1==s2){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
            
        }
    }
    
    
    return 0;
}

C++: #include<stdio.h>
 
int main(){
    int a;
    scanf("%d",&a);
    for(int i=0;i<a;i++){
        double x1,x2,x3,x4,y1,y2,y3,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if(x1==x2&&x3==x4)printf("YES\n");
        else{
            if((y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))printf("YES\n");
            else printf("NO\n");
        }
    }
}