NY-68-three-point sequence [WATER] [ry]

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 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;}         

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.