使用面积法与矢量叉积即可。
代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct Point
{
	double x,y;
	
	Point() {}
	Point(double X,double Y) :x(X),y(Y) {}
	Point operator + (const Point a)const { return Point(a.x+x,a.y+y); }
	Point operator - (const Point a)const { return Point(x-a.x,y-a.y); }
	Point operator * (const double a)const { return Point(x*a,y*a); }
	double operator * (const Point a)const { return x*a.y-y*a.x; }
	void read() { scanf("%lf %lf",&x,&y); }
	void print() { printf("%lf %lf\n",x,y); }
}A,B,C,D;
Point cross(Point p1,Point v1,Point p2,Point v2)
{
	double t=((p2-p1)*v2)/(v1*v2);
	return p1+v1*t;
}
int main()
{
	A.read(),B.read(),C.read(),D.read();
	cross(A,B-A,C,D-C).print();
	return 0;
}
原文:https://www.cnblogs.com/With-penguin/p/13228509.html