feat: add quiz 3 cross-checker.
This commit is contained in:
38
cross-checker/include/cross-checker.h
Normal file
38
cross-checker/include/cross-checker.h
Normal 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
|
Reference in New Issue
Block a user