题目链接:http://poj.org/problem?id=1269

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn = ;
const int maxe = ;
const int INF = 0x3f3f3f;
const double eps = 1e-;
const double PI = acos(-1.0); struct Point{
double x,y;
Point(double x=, double y=) : x(x),y(y){ } //构造函数
};
typedef Point Vector; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (Vector A , double p){return Vector(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
}
int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; }
double Length(Vector A) { return sqrt(Dot(A,A)); } Point GetLineIntersecion(Point P, Vector v,Point Q,Vector w){
Vector u = P - Q;
double t = Cross(w,u)/Cross(v,w);
return P + v*t;
} Point read_point(){
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} /******************************分割线*******************************/ Point P1,P2,Q1,Q2;
int N; int main()
{
// freopen("E:\\acm\\input.txt","r",stdin);
cin>>N;
printf("INTERSECTING LINES OUTPUT\n");
while(N--){
P1 = read_point();
P2 = read_point();
Q1 = read_point();
Q2 = read_point();
if(dcmp(Cross(P2-P1,Q2-Q1))==){ //平行或重合;
if(dcmp(Cross(P1-Q1,P1-Q2)) == ) printf("LINE\n");
else printf("NONE\n");
}
else{ //相交;
Point A = GetLineIntersecion(P1,P2-P1,Q1,Q2-Q1);
printf("POINT %.2f %.2f\n",A.x,A.y);
}
}
printf("END OF OUTPUT\n");
}

最新文章

  1. pImpl
  2. Adobe AIR 中为不同尺寸和分辨率屏幕适配
  3. OpenGl从零开始之坐标变换
  4. vs2010打包winform程序详解
  5. JTree用法及JTree使用经验总结
  6. ocos 信号量
  7. oninput,onpropertychange,onchange的使用方法和差别
  8. rabbitmq-message(C#)
  9. nlpir分词器过期处理
  10. 简述MyBatis的体系结构
  11. 【Nginx系列】Nginx虚拟主机的配置核日志管理
  12. linux下的Shell编程(7)使用-x和-n调试shell程序
  13. 20165306 Exp3 免杀原理与实践
  14. Python类——面向对象
  15. jquery表单提交的新写法
  16. jQuery-2.DOM---节点的复制与替换
  17. Linux MySQL 安装、远程访问和密码重置
  18. orcale存储过程学习之路--创建空存储过程(二)
  19. 阿里云小规模web集群分享(电商)
  20. HttpApplicationState与HttpApplication

热门文章

  1. How to customize authentication to my own set of tables in asp.net web api 2?
  2. 文字排版--粗体(font-weight)
  3. 2016.7.13abstract
  4. 关于点击空白关闭弹窗的js写法推荐?
  5. Java线程运行轨迹-代码追踪与定位
  6. import uno 错误
  7. [r]Setting up Django and your web server with uWSGI and nginx
  8. MySQL 执行计划explain详解
  9. JSP HTML区别
  10. iOS题