Nyist 68 three-point order

Source: Internet
Author: User
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 30 1 1 0 0 00 0 0 0 0 0
Sample output
01














# Include <stdio. h>
Int main ()
{
Int X1, Y1, X2, Y2, X3, Y3;
Double S;
While (scanf ("% d", & X1, & Y1, & X2, & Y2, & X3, & Y3) & X1 + X2 + X3 + Y1 + y2 + Y3)
{
S = x1 * y2 + X3 * Y1 + x2 * y3-x3 * y2-x2 * y1-x1 * Y3; // The Cross Product of AB and BC vectors ......
If (S <0) printf ("1 \ n ");
Else printf ("0 \ n ");


}
Return 0;
}

 

 

 

Length of the cross product | A × B | it can be interpreted as the area of the parallelogram with a and B as the adjacent edges.

 

 

 

 

 

 

 

 

 

# Include <stdio. h>
# Include <math. h>
Main ()
{
Int x1, x2, X3, Y1, Y2, Y3;
Double S;
While (scanf ("% d", & X1, & Y1, & X2, & Y2, & X3, & Y3 ))
{
If (x1 = 0 & Y1 = 0 & X2 = 0 & y2 = 0 & X3 = 0 & Y3 = 0) break;

S = (x2-x1) * (y3-y1)-(x3-x1) * (y2-y1)/2.0;
If (S> = 0)
Printf ("0 \ n ");
Else
Printf ("1 \ n ");
}
}

 

 

 

 

 

 

# Include <stdio. h>
# Include <math. h>
Main ()
{
Int x1, x2, X3, Y1, Y2, Y3;
Double S;
While (scanf ("% d", & X1, & Y1, & X2, & Y2, & X3, & Y3 ), (X1 | Y1 | X2 | Y2 | X3 | Y3 ))
{

S = (x2-x1) * (y3-y1)-(x3-x1) * (y2-y1)/2.0;
If (S> = 0)
Printf ("0 \ n ");
Else
Printf ("1 \ n ");
}
}

 

 

# Include <iostream>
Using namespace STD;
Int main ()
{
While (1)
{
Int X1, Y1, X2, Y2, X3, Y3;
Cin> x1> Y1> X2> Y2> X3> Y3;

If (x1 = 0 & Y1 = 0 & X2 = 0 & y2 = 0 & X3 = 0 & Y3 = 0) break;

Int AX = x2-x1, ay = y2-y1, BX = x2-x3, by = y2-y3;
If (ax * by-ay * BX <0)
Cout <0 <Endl;

Else
Cout <1 <Endl;

}
}

 

 

 

 

 








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.