Nyoj 683-Point order

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.