分析,该题仅考虑了点与直线的关系,由数学知识可知,若直线表示成 ax+by+c=0, 点(x1,y1)带入原方程,其值若大于0,则点在直线上方,否则在直线下方。代码如下
#include <iostream>
using namespace std;
struct Point
{
int x;
int y;
char type;
//Point(int x, int y, char type) : x(x), y(y), type(type) {}
};
struct Line
{
int d;
int x;
int y;
};
//判断在线上还是线下
int above_below(int x, int y, int line_d, int line_x, int line_y)
{
if ((line_d + x * line_x + y * line_y) > 0)
{
return 1<