Skip to content

Commit 21d436c

Browse files
authored
求两个有向线段的时针关系
1 parent e7679f5 commit 21d436c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Segment-Direction.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <cstdio>
2+
3+
using namespace std;
4+
5+
struct point
6+
{
7+
int x, y;
8+
};
9+
10+
struct segment
11+
{
12+
point begin, end;
13+
};
14+
15+
int direction(segment &base, segment &s)
16+
{
17+
return (s.end.x - s.begin.x) * (base.end.y - base.begin.y) - (base.end.x - base.begin.x) * (s.end.y - s.begin.y);
18+
}
19+
20+
int main()
21+
{
22+
while (true)
23+
{
24+
segment base, s;
25+
scanf("%d%d%d%d%d%d%d%d", &base.begin.x, &base.begin.y, &base.end.x, &base.end.y, &s.begin.x, &s.begin.y, &s.end.x, &s.end.y);
26+
printf("%d\n", direction(base, s));
27+
}
28+
return 0;
29+
}

0 commit comments

Comments
 (0)