poj1269
来源:互联网 发布:淘宝网制作费用 编辑:程序博客网 时间:2024/06/05 03:16
Description
Your program will repeatedly read in four points that define two lines in the x-y plane and determine how and where the lines intersect. All numbers required by this problem will be reasonable, say between -1000 and 1000.
Input
Output
Sample Input
50 0 4 4 0 4 4 05 0 7 6 1 0 2 35 0 7 6 3 -6 4 -32 0 2 27 1 5 18 50 3 4 0 1 2 2 5
Sample Output
INTERSECTING LINES OUTPUTPOINT 2.00 2.00NONELINEPOINT 2.00 5.00POINT 1.07 2.20END OF OUTPUT
#include<stdio.h>
int main()
{
int t;
double x1,y1,x2,y2,x3,y3,x4,y4,x,y,k1,k2,b1,b2;
scanf("%d",&t);
printf("INTERSECTING LINES OUTPUT\n");
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
if(x1==x2&&x3==x4)//两直线斜率都不存在!
{
if(x1==x3)
printf("LINE\n");
else
printf("NONE\n");
}
else if(x1==x2&&x3!=x4)//其中一条斜率不存在
{
k1=(y4-y3)*1.0/(x4-x3);
b1=y3-k1*x3;
x=x1;
y=k1*x+b1;
printf("POINT %.2f %.2f\n",x,y);
}
else if(x1!=x2&&x3==x4)//其中一条斜率不存在
{
k1=(y2-y1)*1.0/(x2-x1);
b1=y1-k1*x1;
x=x3;
y=k1*x+b1;
printf("POINT %.2f %.2f\n",x,y);
}
else if(x1!=x2&&x3!=x4)//两条斜率都存在
{
k1=(y2-y1)*1.0/(x2-x1);
b1=y1-k1*x1;
k2=(y4-y3)*1.0/(x4-x3);
b2=y3-k2*x3;
if(k1==k2)
{
if(b1==b2)
printf("LINE\n");
else
printf("NONE\n");
}
else
{
x=(b1-b2)*1.0/(k2-k1);
y=k1*x+b1;
printf("POINT %.2f %.2f\n",x,y);
}
}
}
printf("END OF OUTPUT\n");
return 0;
}
- poj1269
- poj1269
- POJ1269
- poj1269
- poj1269
- POJ1269(判断线段相交)
- 计算几何POJ1269
- POJ1269 Intersecting Lines
- POJ1269- Intersecting Lines
- Intersecting Lines(poj1269)
- poj1269 直线求交点
- poj1269直线交点
- POJ1269 Intersecting Lines
- POJ1269 Intersecting Lines
- [poj1269]:Intersecting Lines
- 【计算几何】 poj1269 Intersecting Lines
- poj1269 简单的计算几何
- poj1269(计算几何+直线位置)
- 2011.08.06
- java中的集合类 以及 迭代器
- 表达式左值右值(C++学习)
- 刚刚CSDN号发现密码被改了 ...幸好找回来了。。
- the CComObjectRootEx
- poj1269
- tiny6410 Linux启动信息
- Phyx3@CGDC4
- 【教程】Gentoo的安装
- linux 内核中的锁机制--RCU
- android2.2
- 处理身份证相同的情况 2
- the CComSingleThreadModel & the CComMultiThreadModel
- 快速排序