#include<bits/stdc++.h> using namespace std; struct point { double x, y; point(double A, double B) { x = A, y = B; } point() = default; }; struct line { point point_A, point_B; line(point A, point B) { point_A = A, point_B = B; } line() = default; }; point findMeetingPoint(line line_A, line line_B) { // TODO:求直线 line_A 与 line_B 的交点 double x1 = line_A.point_A.x, y1 = line_A.point_A.y; double x2 = line_A.point_B.x, y2 = line_A.point_B.y; double x3 = line_B.point_A.x, y3 = line_B.point_A.y; double x4 = line_B.point_B.x, y4 = line_B.point_B.y; // 计算直线方程的参数 double A1 = y2 - y1; double B1 = x1 - x2; double C1 = x2 * y1 - x1 * y2; double A2 = y4 - y3; double B2 = x3 - x4; double C2 = x4 * y3 - x3 * y4; // 计算分母 double D = A1 * B2 - A2 * B1; // 判断是否平行或重合 if (fabs(D) < 1e-8) { return point(-1, -1); } // 计算交点 double x = (B1 * C2 - B2 * C1) / D; double y = (A2 * C1 - A1 * C2) / D; std::cout << std::fixed << std::setprecision(6); return point(x, y); } int main() { point A, B, C, D; cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y; line AB = line(A, B); line CD = line(C, D); point ans = findMeetingPoint(AB, CD); cout << ans.x << " " << ans.y; return 0; }