poj 1269 Intersecting Lines 线段相交 平行 重合
来源:互联网 发布:c语言中实型常量 编辑:程序博客网 时间:2024/05/16 09:36
利用斜率;斜率相同 在判断是否等同的 如果不是则平行;斜率不同 求交点;#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;}
- poj 1269 Intersecting Lines 线段相交 平行 重合
- POJ 1269 || Intersecting Lines(直线重合,平行,相交判定
- POJ 1269 Intersecting Lines 判断直线间的状态(平行、重合、相交于一点)
- POJ 1269 Intersecting Lines 判断直线关系(相交(求交点),重合,平行)
- POJ 1269 Intersecting Lines(直线相交?平行?重合?,求交点)
- poj 1269 Intersecting Lines(判断线段相交,并求交点)
- POJ 1269 Intersecting Lines(线段相交,水题)
- poj 1269 Intersecting Lines(计算几何:线段相交)
- POJ1269-Intersecting Lines(判断两条直线平行、重合或者相交)
- poj 1269 Intersecting Lines--直线相交
- POJ 1269 Intersecting Lines 判断直线相交
- POJ 1269Intersecting Lines 直线相交判断
- poj 1269 Intersecting Lines 【直线相交】
- Intersecting Lines(判断线段相交)
- 判断两条直线 共线或 平行 或相交 求交点 叉乘的应用 poj 1269 Intersecting Lines
- POJ 1269 判断直线的关系:相交,平行,重合
- poj 1269 Intersecting Lines(判断直线相交 求交点)
- POJ 1269 Intersecting Lines(判断直线相交)
- Mysql 体系结构系列之六
- windows media player 中播放pls的方法
- 用两个栈实现队列 & 两个队列实现一个栈
- Android Http请求方法汇总
- iOS应用中增加emoji表情输入功能
- poj 1269 Intersecting Lines 线段相交 平行 重合
- “Project facet Java version 1.7 is not supported.”
- The Difference Between Encoding, Encryption, and Hashing
- MySQL配置文件优化(Innodb)
- AsyncTask 与 对话框显示 view.WindowManager$BadTokenException: Unable to add window…is not valid; is your a
- 【Win8不好用?简单方法助您还原之前系统】
- hdu 1402 A * B Problem Plus
- UVA 11987 - Almost Union-Find
- POJ-1365-Prime Land