# poj 1269 Intersecting Lines 线段相交 平行 重合

利用斜率；

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double eps = 1e-9;//注意精度；
const double inf = 1e10;

double x1, y, x2, y2, x3, y3, x4, y4;

bool dx(double x1, double x2)
{
return abs(x1-x2) < eps;//两点相同；
}

double xl(double x1, double y1, double x2, double y2)//求斜率；
{
if(dx(x1, x2)) return inf;//平行y轴 无斜率；
return (y1-y2)/(x1-x2);
}

int main()
{
int t;
cout << "INTERSECTING LINES OUTPUT" << endl;
scanf("%d", &t);
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y, &x2, &y2, &x3, &y3, &x4, &y4);
double k1 = xl(x1, y, x2, y2), k2 = xl(x3, y3, x4, y4);
if(dx(k1, k2))
{
if((dx(x1, x2) && dx(x1, x3)) ||(dx((y-k1*x1), (y3-k2*x3)))) cout << "LINE" << endl;
else cout << "NONE" << endl;
}
else
{
double b1 = y-k1*x1, b2 = y3-k2*x3;
printf("POINT %.2lf %.2lf\n", (b1-b2)/(k2-k1), k1*(b1-b2)/(k2-k1)+b1);
}
}
cout << "END OF OUTPUT" << endl;
return 0;
}


05-16 699

10-28 287
08-07 1464
11-07 665
09-03 653
08-14 152
08-22 930
07-26 1121
11-19 26
08-03 70
06-16 4215