计算几何入门
无非是平行, 重合和相交
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <sstream>
#include <queue>
#include <vector>
#define MAXN 100005
#define MAXM 211111
#define eps 1e-8
#define INF 500000001
using namespace std;
inline int dblcmp(double d)
{if(fabs(d) < eps) return 0;return d > eps ? 1 : -1;
}
struct point
{double x, y;point(){}point(double _x, double _y): x(_x), y(_y) {}void input(){scanf("%lf%lf", &x, &y);}bool operator ==(point a)const{return dblcmp(a.x - x) == 0 && dblcmp(a.y - y) == 0;}point sub(point p){return point(x - p.x, y - p.y);}double det(point p){return x * p.y - y * p.x;}}p[3333];
struct line
{point a, b;line(){}line(point _a, point _b){ a = _a; b = _b;}void input(){a.input();b.input();}int relation(point p){int c = dblcmp(p.sub(a).det(b.sub(a)));if (c < 0) return 1;if (c > 0) return 2;return 3;}bool parallel(line v){return dblcmp(b.sub(a).det(v.b.sub(v.a))) == 0;}int linecrossline(line v){if ((*this).parallel(v)){return v.relation(a) == 3;}return 2;}point crosspoint(line v){double a1 = v.b.sub(v.a).det(a.sub(v.a));double a2 = v.b.sub(v.a).det(b.sub(v.a));return point((a.x * a2 - b.x * a1) / (a2 - a1), (a.y * a2 - b.y * a1) / (a2 - a1));}}X, Y;
int n;
int main()
{puts("INTERSECTING LINES OUTPUT");scanf("%d", &n);for(int i = 0; i < n; i++){X.input();Y.input();int c = X.linecrossline(Y);if(c == 0) puts("NONE");else if(c == 1) puts("LINE");else{point a = X.crosspoint(Y);printf("POINT %.2f %.2f\n", a.x, a.y);}}puts("END OF OUTPUT");return 0;
}