Language: C++

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

//??????????????????0??¨???????¢?????????????????????¨??????
#define DEBUG 1

class D3
{
public:
	long double X, Y, Z, EPS;

	D3( long double, long double, long double );
	bool operator== ( D3 Partner );
	bool operator==( long double );
	D3 operator*( long double );
	D3 operator/( long double );

	friend ostream& operator<<( ostream& os, const D3& );
};

class Point :private D3
{
public:
	Point( long double, long double, long double );
	long double getX();
	long double getY();
	long double getZ();

	bool operator== ( Point );
	bool operator<( Point );
	bool operator>( Point );
	friend bool operator<( const Point&, const Point& );
	friend bool operator>( const Point&, const Point& );
	long double S_point( Point, Point );
	long double V_point( Point, Point, Point );

	friend ostream& operator<<( ostream& os, const Point& );
};

class Vec
{
private:
	Point SP;//Starting Point ?§????
	D3 D;//Direction ??????

	Vec( D3 Direction_, Point SP_ );
public:
	Vec( long double x_, long double y_, long double z_, Point );
	Vec operator+( Vec Partner );
	Vec operator*( Vec Partner );
	Vec operator*( long double ld );
	Vec operator-( Vec Partner );
	Vec operator/( Vec Partner );
	Vec operator/( long double );
	bool operator== ( Vec );
	bool operator==( long double );
	Vec Cross_product( Vec );
	double Inner_product( Vec );
	Vec( Point A, Point B );
	Point getSP();
	Point getGP();
	D3 getD();
	long double length();
	Vec Unit_vec();
	Vec Inverse_vec();
	Vec Reverse_vec();
	bool Vertical( Vec );
	bool Parallel( Vec );
	bool isIntersection( Vec );
	Point IntersectionPoint( Vec );
	bool onVecPoint( Point );
	long double S_vec( Vec );
	long double V_vec( Vec, Vec );

	friend ostream& operator<<( ostream& os, const Vec& );

};


//D3

D3::D3( long double x_ = 0.0L, long double y_ = 0.0L, long double z_ = 0.0L ) {
	X = x_;
	Y = y_;
	Z = z_;
	EPS = 1e-9L;
}

bool D3::operator== ( D3 Partner ) {
	return abs( X - Partner.X ) < EPS&&abs( Y - Partner.Y ) < EPS&&abs( Z - Partner.Z ) < EPS;
}

bool D3::operator==( long double ld ) {
	return (*this) == D3();
}

D3 D3::operator*( long double ld ) {
	return D3( X*ld, Y*ld, Z*ld );
}

D3 D3::operator/( long double ld ) {
	return  *this*(ld*-1.L);
}

ostream& operator<<( ostream& os, const D3& d ) {
	if( DEBUG ) {
		os << "D3" << endl;
		os << "X:" << d.X << endl;
		os << "Y:" << d.Y << endl;
		os << "Z:" << d.Z << endl;
	}
	return os;
}


//Point

Point::Point( long double x_ = 0.0L, long double y_ = 0.0L, long double z_ = 0.0L ) {
	X = x_;
	Y = y_;
	Z = z_;
}

//x??§?¨??????????
long double Point::getX() {
	return X;
}

//y??§?¨??????????
long double Point::getY() {
	return Y;
}

//z??§?¨??????????
long double Point::getZ() {
	return Z;
}

bool Point::operator== ( Point Partner ) {
	return D3( *this ) == D3( Partner );
}
bool Point::operator<( Point Partner ) {
	if( (*this).getX() != Partner.getX() ) {
		return (*this).getX() < Partner.getX();
	}
	if( (*this).getY() != Partner.getY() ) {
		return (*this).getY() < Partner.getY();
	}
	return (*this).getZ() < Partner.getZ();

}
bool Point::operator>( Point Partner ) {
	return Partner < (*this);
}
//??????????????¢???????±???????
long double Point::S_point( Point B, Point C ) {
	Vec AB( *this, B ), AC( *this, C );
	return AB.S_vec( AC );
}

//??????????????????????±???????
long double Point::V_point( Point B, Point C, Point D ) {
	return Vec( (*this), B ).V_vec( Vec( (*this), C ), Vec( (*this), D ) );
}


ostream & operator<<( ostream & os, const Point &p ) {
	if( DEBUG ) {
		os << "Point" << endl;
		os << "X:" << p.X << endl;
		os << "Y:" << p.Y << endl;
		os << "Z:" << p.Z << endl;
	}
	return os;
}

bool operator<( const Point& p1, const Point& p2 ) {
	if( p1.X == p2.X ) {
		if( p1.Y == p2.Y ) {
			return p1.Z < p2.Z;
		}
		return p1.Y < p2.Y;
	}
	return p1.X < p2.X;
}

bool operator>( const Point& p1, const Point& p2 ) {
	return p2 < p1;
}


//Vec

//??????????????¨?§???????????????????????????????
Vec::Vec( D3 Direction_, Point SP_ ) {
	D = Direction_;
	SP = SP_;
}

//?§??????¨???????????????????????????????????????????????????
Vec::Vec( long double x_ = 0.0L, long double y_ = 0.0L, long double z_ = 0.0L, Point SP_ = Point() ) {
	*this = Vec( D3( x_, y_, z_ ), SP_ );
}

Vec Vec::operator+( Vec Partner ) {
	return Vec( D.X + Partner.D.X, D.Y + Partner.D.Y, D.Z + Partner.D.Z, SP );
}

Vec Vec::operator*( Vec Partner ) {
	return Vec( D.X * Partner.D.X, D.Y * Partner.D.Y, D.Z * Partner.D.Z, SP );
}

Vec Vec::operator*( long double ld ) {
	return Vec( D*ld, SP );
}

Vec Vec::operator-( Vec Partner ) {
	return *this + (Partner*(-1.L));
}


Vec Vec::operator/( Vec Partner ) {
	return Vec( D.X / Partner.D.X, D.Y / Partner.D.Y, D.Z / Partner.D.Z, SP );
}

Vec Vec::operator/( long double ld ) {
	return *this*(1.L / ld);
}

bool Vec::operator== ( Vec Partner ) {
	return D == Partner.D&&SP == Partner.SP;
}

bool Vec::operator==( long double ) {
	return (*this) == Vec();
}

//??????
Vec Vec::Cross_product( Vec Partner ) {
	return Vec( D.Y*Partner.getD().Z - D.Z*Partner.getD().Y, D.Z*Partner.getD().X - D.X*Partner.getD().Z, D.X*Partner.getD().Y - D.Y*Partner.getD().X );
}

//??????
double Vec::Inner_product( Vec Partner ) {
	return D.X*Partner.getD().X + D.Y*Partner.getD().Y + D.Z*Partner.getD().Z;
}

//???????????????????????????????????????
Vec::Vec( Point A, Point B ) {
	*this = Vec( B.getX() - A.getX(), B.getY() - A.getY(), B.getZ() - A.getZ(), A );
}

//?§?????????????
Point Vec::getSP() {
	return SP;
}

//???????????????
Point Vec::getGP() {
	return Point( SP.getX() + D.X, SP.getY() + D.Y, SP.getZ() + D.Z );
}

//???????????????
D3 Vec::getD() {
	return D;
}

//???????????????
long double Vec::length() {
	return sqrtl( D.X*D.X + D.Y*D.Y + D.Z*D.Z );
}

//??????????????????(??????1)?????????
Vec Vec::Unit_vec() {
	return Vec( *this ) / (*this).length();
}

//????????????????????????(?§??????????????????????)
Vec Vec::Inverse_vec() {
	return (*this)*-1.L;
}

//????????????????????????(?§??????¨???????????\????????????)
Vec Vec::Reverse_vec() {
	return Vec( (*this).Inverse_vec().getD(), (*this).getGP() );
}

//?????´????????????
bool Vec::Vertical( Vec Partner ) {
	return (*this).Inner_product( Partner ) == 0;
}

//??????????????????
bool Vec::Parallel( Vec Partner ) {
	return (*this).Unit_vec().getD() == Partner.Unit_vec().getD() || (*this).Unit_vec().Inverse_vec().getD() == Partner.Unit_vec().getD();
}

//??????????????????????????????????????????????????????
bool Vec::isIntersection( Vec Partner ) {
	int count = 0;
	Vec O = Partner.Cross_product( Vec( Partner.getSP(), (*this).getSP() ) );
	Vec P = Partner.Cross_product( Vec( Partner.getSP(), (*this).getGP() ) );
	Vec Q = (*this).Cross_product( Vec( (*this).getSP(), Partner.getSP() ) );
	Vec R = (*this).Cross_product( Vec( (*this).getSP(), Partner.getGP() ) );
	return (!(*this).Parallel( Partner )) && (
		O.getD().X*P.getD().X < D3().EPS&& O.getD().Y*P.getD().Y < D3().EPS&& O.getD().Z*P.getD().Z < D3().EPS) && (
			Q.getD().X*R.getD().X < D3().EPS&& Q.getD().Y*R.getD().Y < D3().EPS&& Q.getD().Z*R.getD().Z < D3().EPS);
}

//????????????????£???????????????????
//?????????????????????????????????????¢???????????????¨???
//TODO:???????£?
Point Vec::IntersectionPoint( Vec Partner ) {
	if( (*this).isIntersection( Partner ) ) {
		//cout << Partner << endl;
		long double d1 = abs( Partner.Cross_product( Vec( Partner.getSP(), (*this).getSP() ) ).D.Z );
		long double d2 = abs( Partner.Cross_product( Vec( Partner.getSP(), (*this).getGP() ) ).D.Z );
		//cout << fixed << setprecision( 20 ) << Vec( Partner.getSP(), (*this).getSP() ).length() << endl;
		long double t = d1 / (d1 + d2);
		return Vec( ((*this)*t).getD(), (*this).getSP() ).getGP();
	} else {
		return Point();
	}
	return Point();
}

//????????????????????????????????????????????????????????????
bool Vec::onVecPoint( Point A ) {
	Vec Test( (*this).getSP(), A );
	if( A == ((*this).getSP()) || (Test.Parallel( *this ) && (*this).getD().X / Test.getD().X >= 1.0L) ) {
		return true;
	}
	return false;
}

//???????§????2????????????????????¢???????±???????
long double Vec::S_vec( Vec B ) {
	if( ((*this).getSP() == B.getSP()) ) {
		Vec G = (*this).Cross_product( B );
		return sqrtl( G.Inner_product( G ) ) / 2.L;
	}
	if( (*this).getGP() == B.getSP() ) {
		return (*this).Reverse_vec().S_vec( B );
	}
	if( (*this).getSP() == B.getGP() ) {
		return (*this).S_vec( B.Reverse_vec() );
	}
	if( (*this).getGP() == B.getGP() ) {
		return (*this).Reverse_vec().S_vec( B.Reverse_vec() );
	}

	return -1.L;
}

//???????§???????????????????????????¨?§???????????????£??????????????????????????????
//?????????????????¨??????????????????????????????
//TODO ?§??????¨?????????????????????
long double Vec::V_vec( Vec B, Vec C ) {
	Vec G = (*this).Cross_product( B );
	return G.Inner_product( C ) / 6.L;
	return 0;
}

ostream & operator<<( ostream & os, const Vec &v ) {
	if( DEBUG ) {
		os << "Vec" << endl;
		os << "start point" << endl;
		os << v.SP << endl;
		os << "vec" << endl;
		os << v.D << endl;
	}
	return os;
}



class Points
{
private:
	vector<Point>VP;

public:
	void push( Point p ) {
		VP.push_back( p );
	}
	bool erase( Point p ) {
		auto now = find( VP.begin(), VP.end(), p );
		if( now != VP.end() ) {
			VP.erase( now );
			return 0;
		} else {
			return 1;
		}
	}

	void print() {
		for( auto x : VP ) {
			cout << x << endl;
		}
	}

	//sort????????????X?????§?°?->Y?????§?°?->Z?????§?°????
	void sort() {
		std::sort( VP.begin(), VP.end() );
	}

};

class PointDistance
{
public:
	vector <int> findPoint( int x1, int y1, int x2, int y2 ) {
		Point A( x1, y1 ), B( x2, y2 );
		for( int i = -100; i <= 100; i++ ) {
			for( int j = -100; j <= 100; j++ ) {
				if( Vec( A, Point( i, j ) ).length() > Vec( B, Point( i, j ) ).length() && Vec( B, Point( i, j ) ).length() >= 1 ) {
					return vector<int>{i, j };
				}
			}
		}


	}
};

int main() {
	long long int q;
	cin >> q;
	for( size_t i = 0; i < q; i++ ) {
		vector<Point>VP( 4 );
		for( size_t j = 0; j < 4; j++ ) {
			long long int x, y;
			cin >> x >> y;
			VP[j] = Point( x, y );
		}
		Vec s1( VP[0], VP[1] ), s2( VP[2], VP[3] );
		auto cross = s1.IntersectionPoint( s2 );
		cout << fixed << setprecision( 20 ) << cross.getX() << " ";
		cout << fixed << setprecision( 20 ) << cross.getY() << endl;

	}
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:18:16: error: 'ostream' does not name a type
   18 |         friend ostream& operator<<( ostream& os, const D3& );
      |                ^~~~~~~
a.cc:37:16: error: 'ostream' does not name a type
   37 |         friend ostream& operator<<( ostream& os, const Point& );
      |                ^~~~~~~
a.cc:75:16: error: 'ostream' does not name a type
   75 |         friend ostream& operator<<( ostream& os, const Vec& );
      |                ^~~~~~~
a.cc: In member function 'bool D3::operator==(D3)':
a.cc:90:16: error: 'abs' was not declared in this scope
   90 |         return abs( X - Partner.X ) < EPS&&abs( Y - Partner.Y ) < EPS&&abs( Z - Partner.Z ) < EPS;
      |                ^~~
a.cc: At global scope:
a.cc:105:1: error: 'ostream' does not name a type
  105 | ostream& operator<<( ostream& os, const D3& d ) {
      | ^~~~~~~
a.cc:167:1: error: 'ostream' does not name a type
  167 | ostream & operator<<( ostream & os, const Point &p ) {
      | ^~~~~~~
a.cc: In member function 'long double Vec::length()':
a.cc:270:16: error: 'sqrtl' was not declared in this scope
  270 |         return sqrtl( D.X*D.X + D.Y*D.Y + D.Z*D.Z );
      |                ^~~~~
a.cc: In member function 'Point Vec::IntersectionPoint(Vec)':
a.cc:316:34: error: 'abs' was not declared in this scope
  316 |                 long double d1 = abs( Partner.Cross_product( Vec( Partner.getSP(), (*this).getSP() ) ).D.Z );
      |                                  ^~~
a.cc: In member function 'long double Vec::S_vec(Vec)':
a.cc:340:24: error: 'sqrtl' was not declared in this scope
  340 |                 return sqrtl( G.Inner_product( G ) ) / 2.L;
      |                        ^~~~~
a.cc: At global scope:
a.cc:364:1: error: 'ostream' does not name a type
  364 | ostream & operator<<( ostream & os, const Vec &v ) {
      | ^~~~~~~
a.cc:380:9: error: 'vector' does not name a type
  380 |         vector<Point>VP;
      |         ^~~~~~
a.cc: In member function 'void Points::push(Point)':
a.cc:384:17: error: 'VP' was not declared in this scope
  384 |                 VP.push_back( p );
      |                 ^~
a.cc: In member function 'bool Points::erase(Point)':
a.cc:387:34: error: 'VP' was not declared in this scope
  387 |                 auto now = find( VP.begin(), VP.end(), p );
      |                                  ^~
a.cc:387:28: error: 'find' was not declared in this scope
  387 |                 auto now = find( VP.begin(), VP.end(), p );
      |                            ^~~~
a.cc: In member function 'void Points::print()':
a.cc:397:31: error: 'VP' was not declared in this scope
  397 |                 for( auto x : VP ) {
      |                               ^~
a.cc:398:25: error: 'cout' was not declared in this scope
  398 |                         cout << x << endl;
      |                         ^~~~
a.cc:398:38: error: 'endl' was not declared in this scope
  398 |                         cout << x << endl;
      |                                      ^~~~
a.cc: In member function 'void Points::sort()':
a.cc:404:22: error: 'sort' is not a member of 'std'
  404 |                 std::sort( VP.begin(), VP.end() );
      |                      ^~~~
a.cc:404:28: error: 'VP' was not declared in this scope
  404 |                 std::sort( VP.begin(), VP.end() );
      |                            ^~
a.cc: At global scope:
a.cc:412:9: error: 'vector' does not name a type
  412 |         vector <int> findPoint( int x1, int y1, int x2, int y2 ) {
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:428:9: error: 'cin' was not declared in this scope
  428 |         cin >> q;
      |         ^~~
a.cc:429:14: error: 'size_t' was not declared in this scope
  429 |         for( size_t i = 0; i < q; i++ ) {
      |              ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | include <bits/stdc++.h>
a.cc:429:28: error: 'i' was not declared in this scope
  429 |         for( size_t i = 0; i < q; i++ ) {
      |                            ^
a.cc:430:17: error: 'vector' was not declared in this scope
  430 |                 vector<Point>VP( 4 );
      |                 ^~~~~~
a.cc:430:29: error: expected primary-expression before '>' token
  430 |                 vector<Point>VP( 4 );
      |                             ^
a.cc:430:30: error: 'VP' was not declared in this scope
  430 |                 vector<Point>VP( 4 );
      |                              ^~
a.cc:431:28: error: expected ';' before 'j'
  431 |                 for( size_t j = 0; j < 4; j++ ) {
      |                            ^~
      |                            ;
a.cc:431:36: error: 'j' was not declared in this scope
  431 |                 for( size_t j = 0; j < 4; j++ ) {
      |                                    ^
a.cc:438:17: error: 'cout' was not declared in this scope
  438 |                 cout << fixed << setprecision( 20 ) << cross.getX() << " ";
      |                 ^~~~
a.cc:438:25: error: 'fixed' was not declared in this scope
  438 |                 cout << fixed << setprecision( 20 ) << cross.getX() << " ";
      |                         ^~~~~
a.cc:438:34: error: 'setprecision' was not declared in this scope
  438 |                 cout << fixed << setprecision( 20 ) << cross.getX() << " ";
      |                                  ^~~~~~~~~~~~
a.cc:439:72: error: 'endl' was not declared in this scope
  439 |                 cout << fixed << setprecision( 20 ) << cross.getY() << endl;
      |                                                                        ^~~~