POJ 1269 (直线相交) Intersecting Lines】的更多相关文章

水题,以前总结的模板还是很好用的. #include <cstdio> #include <cmath> using namespace std; ; int dcmp(double x) { ; ? - : ; } struct Point { double x, y; Point(, ):x(x), y(y) {} }; typedef Point Vector; Point read_point() { double x, y; scanf("%lf%lf"…
POJ原题 ZOJ原题 多组数据.每次给出四个点,前两个点确定一条直线,后两个点确定一条直线,若平行则输出"NONE",重合输出"LINE",相交输出"POINT"+交点坐标(保留两位小数) 先判重合:两条线重合意味着四点共线,即ABC共线且ABD共线(共线即为叉积=0) 再判平行:正常的数学方法,\(\overrightarrow{AB}\) // \(\overrightarrow{CD}\) 求交点: //这个公式很好用,背下来好伐 #in…
Problem Intersecting Lines (POJ 1269) 题目大意 给定两条直线,问两条直线是否重合,是否平行,或求出交点. 解题分析 主要用叉积做,可以避免斜率被0除的情况. 求交点P0: 已知P1 P2 P3 P4 运用 P0P1 X P0P2 = 0 和 P0P3 X P0P4 = 0 C++ 用%.2lf g++ 用 %.2f!!! C++ 用%.2lf g++ 用 %.2f!!! C++ 用%.2lf g++ 用 %.2f!!! 参考程序 #include <cstd…
模板题 注意原题中说的线段其实要当成没有端点的直线.被坑了= = #include <cmath> #include <cstdio> #include <iostream> #include <cstring> using namespace std; #define eps 1e-8 #define PI acos(-1.0)//3.14159265358979323846 //判断一个数是否为0,是则返回true,否则返回false #define z…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9360   Accepted: 4210 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
id=1269" rel="nofollow">Intersecting Lines 大意:给你两条直线的坐标,推断两条直线是否共线.平行.相交.若相交.求出交点. 思路:线段相交推断.求交点的水题.没什么好说的. struct Point{ double x, y; } ; struct Line{ Point a, b; } A, B; double xmult(Point p1, Point p2, Point p) { return (p1.x-p.x)*(p2…
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0)=0 (p3-p0)X(p2-p0)=0 展开后即是 (y1-y2)x0+(x2-x1)y0+x1y2-x2y1=0 (y3-y4)x0+(x4-x3)y0+x3y4-x4y3=0 将x0,y0作为变量求解二元一次方程组. 假设有二元一次方程组 a1x+b1y+c1=0; a2x+b2y+c2=0…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8342   Accepted: 3789 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题意:    判断直线间位置关系: 相交,平行,重合 include <iostream> #include <cstdio> using namespace std; struct Point { int x , y; Point(, ) :x(a), y(b) {} }; struct Line { Point s, e; int a, b, c;//a>=0 Line() {} Line(Point s1,Point e1) : s(s1), e(e1) {} void…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8637   Accepted: 3915 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…