求大神解决C++的问题!!?

2025-03-22 07:39:01
推荐回答(2个)
回答1:

#include
typedef struct{ int x, y; } direction;
int visible(direction s, direction A, direction B, direction C)
{
direction p1, p2;
int d;
p1.x = B.x - A.x; // -1
p1.y = B.y - A.y; // -1
p2.x = C.x - A.x; // 1
// 下面这行是不是应该p2.y
p1.y = C.y - A.y; // 0

//   1  *  -1  *   1  +  1  *  -1  *  undefined
d = s.x * p1.x * p2.x + s.y * p1.y * p2.y;

printf("M\n", d);
return d>0;
}

void main()
{
char *ss[] = { "invisible", "visible" };
direction s = { 1, 1 }, T = { 1, 1 }, A = { 0, 0 }, B = { 2, 1 };
puts(ss[visible(s, T, A, B)]);
}

回答2:

这个结果是什么