Three-point sequential time limit: 1000 MS | memory limit: 65535 KB
Difficulty: 3
-
-
Description
-
-
The coordinates of the three non-collocated vertices A, B, and C must be A triangle. Now let you determine the coordinates of A, B, is C provided clockwise or counterclockwise?
-
For example:
-
Figure 1: clockwise
-
Figure 2: counter-clockwise
-
<Figure 1> <Figure 2>
-
-
-
Input
Each row is A set of test data, with six integers x1, y1, x2, y2, x3, and y3 representing the horizontal and vertical coordinates of A, B, and C. (The coordinates are between 0 and 10000)
Input 0 0 0 0 0 0 indicates input is complete
Test data cannot exceed 10000 groups
-
Output
If the three points are clockwise, output 1, and output 0
-
Sample Input
-
-
0 0 1 1 1 3
0 1 1 0 0 0
0 0 0 0 0 0
-
-
Sample output
-
0
1
Code:
Vector cross product. Pay attention to the direction and order of cross Multiplication...
#include<stdio.h>#include<math.h>int main(){int x1,x2,x3,y1,y2,y3;double ans;while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3),x1||x2||x3||y1||y2||y3){ans = (x2-x1)*(y3-y1) - (y2-y1)*(x3-x1);if(ans>0) printf("0\n");else printf("1\n");}return 0;}