Three-point sequential time limit: +Ms | Memory Limit:65535KB Difficulty:3
-
-
Describe
-
Now give you the coordinates of the three point a,b,c, they must be able to form a triangle, now let you judge whether A,b,c is given clockwise or counterclockwise?
Such as:
Figure 1: Clockwise given
Figure 2: Counter-clockwise
< figure 1> < figure 2>
-
-
Input
-
-
each row is a set of test data, with 6 integer x1,y1,x2,y2,x3,y3 representing the horizontal ordinate of a,b,c three points, respectively. (Coordinate values from 0 to 10000)
Input 0 0 0 0 0 0 indicates end of input
No more than 10000 test data sets
-
-
Output
-
-
If these three points are given clockwise, output 1, counter-clockwise, output 0
-
-
Sample input
-
-
0 0 1 1 1 30 1 1 0 0 00 0 0 0 0 0
-
-
Sample output
-
-
01
Triangle ABC three vertices are counter-clockwise, the direction area is positive, clockwise arrangement is negative, three points collinear, the direction area is 0;
Ab= (X2-x1,y2-y1), ac= (x3-x1,y3-y1)
The cross-product of AB and AC is: (2*2 determinant) |x2-x1, y2-y1| | X3-X1, the y3-y1| value is: (x2-x1) * (y3-y1)-(y2-y1) * (X3-X1)
The ab*ac>0 is reversed, whereas the reverse is
#include <stdio.h> int main () { int x1,y1,x2,y2,x3,y3; while (scanf ("%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3), x1| | x2| | x3| | y1| | y2| | Y3) { if (x1*y2+x2*y1+x2*y3-x3*y2-x1*y3-x3*y1<0) printf ("1\n"); else printf ("0\n"); } return 0;}
Nyoj 683-Point order