http://poj.org/problem?id=1269
真是个令人忧桑的故事。。。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,l,r) for(int i=(l),_=(r);i<=_;i++)
#define per(i,r,l) for(int i=(r),_=(l);i>=_;i--)
#define MS(arr,x) memset(arr,x,sizeof(arr))
#define INE(i,u) for(int i=head[u];~i;i=e[i].next)
#define LL long long
#define Vector Point
#define data pair<Point,int>
inline const int read()
{int r=0,k=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')k=-1;
for(;c>='0'&&c<='9';c=getchar())r=r*10+c-'0';return k*r;}
const double eps=1e-8;
double dcmp(double x){if(fabs(x)<eps)return 0;return x>0?1:-1;}
struct Point{
double x,y;
Point(){}
Point(double x,double y):x(x),y(y){}
Point operator+(const Point &b)const{return Point(x+b.x,y+b.y);}
Vector operator-(const Point &b)const{return Point(x-b.x,y-b.y);}
Point operator*(const double &b)const{return Point(x*b,y*b);}
double operator^(Point b)const{return x*b.y-y*b.x;}
};
struct Line{
Point p,v;
Line(){}
Line(Point p,Vector v):p(p),v(v){}
data operator&(Line &b)
{
double x=v^b.v,y=b.v^p-b.p;
if(!x)
{
if(y) return (data){p,-1};
else return (data){p,1};
}
return (data){p+v*(y/x),0};
}
};
struct Seg{
Point s,t;
}a,b;
void input()
{
scanf("%lf%lf%lf%lf",&a.s.x,&a.s.y,&a.t.x,&a.t.y);
scanf("%lf%lf%lf%lf",&b.s.x,&b.s.y,&b.t.x,&b.t.y);
}
void solve()
{
Line la=Line(a.s,a.t-a.s);
Line lb=Line(b.s,b.t-b.s);
pair<Point,int> ret=la&lb;
if(ret.second==-1) puts("NONE");
else if(ret.second==1) puts("LINE");
else printf("POINT %.2f %.2f\n",ret.first.x,ret.first.y);
}
int main()
{
//freopen("_.in","r",stdin); freopen("_.out","w",stdout);
puts("INTERSECTING LINES OUTPUT");
rep(i,1,read())
input(),solve();
puts("END OF OUTPUT");
return 0;
}