三点顺序

三点顺序

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
 
描述

现在给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,现在让你判断A,B,C是顺时针给出的还是逆时针给出的?

如:

图1:顺时针给出

图2:逆时针给出 

 

        <图1>                   <图2>

 
输入
每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示A,B,C三个点的横纵坐标。(坐标值都在0到10000之间)
输入0 0 0 0 0 0表示输入结束
测试数据不超过10000组
输出
如果这三个点是顺时针给出的,请输出1,逆时针给出则输出0
样例输入
0 0 1 1 1 3
0 1 1 0 0 0
0 0 0 0 0 0
样例输出
0
1

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main(int argc, char* argv[])
{
int x1,y1,x2,y2,x3,y3;
int x12,x13,y12,y13;
while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3)&&(x1||x2||x3||y1||y2||y3))
{
x12=x2-x1;
y12=y2-y1;
x13=x3-x1;
y13=y3-y1;
if(x12*y13-x13*y12<0) printf("1\n");
else printf("0\n");
}
return 0;
}

posted on 2014-04-24 22:55  52Cyan  阅读(113)  评论(0编辑  收藏  举报

导航