feat: add quiz 3 cross-checker.

This commit is contained in:
2025-05-19 21:56:26 +08:00
parent a4624b477f
commit 3bfb4dde2e
9 changed files with 163 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
//
// Created by ricardo on 19/05/25.
//
#ifndef CROSS_CHECKER_H
#define CROSS_CHECKER_H
namespace cross_checker
{
// 既可以表示点也可以表示一个向量
struct Point
{
double x;
double y;
Point(const double a, const double b) : x(a), y(b)
{
}
static int orientation(const Point& p, const Point& q, const Point& r);
static bool onSegment(const Point& p, const Point& q, const Point& r);
};
struct Line
{
Point startPoint;
Point endPoint;
Line(const Point a, const Point b): startPoint(a), endPoint(b)
{
}
bool intersect(const Line& other);
};
}
#endif //CROSS_CHECKER_H