您的位置:首页 > 其它

nyist68 三点顺序(用叉乘判断向量的方向)

2016-02-15 14:40 309 查看
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=68

思路:

p*q>0,则p在q的顺时针方向

p*q<0,则p在q的逆时针方向

p*q=0,则p与q共线,但可能同向也可能反向

AC代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <climits>
#include <cmath>
#include <cctype>

const int inf = 0x7f7f7f7f;//2139062143
typedef long long ll;
using namespace std;

int main()
{
int x1,x2,x3,y1,y2,y3;
while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3))
{
if(x1+x2+x3+y1+y2+y3 == 0)
break;
int sum = (x1-x2)*(y3-y2)-(x3-x2)*(y1-y2);
if(sum > 0)
{
printf("1\n");
}
else
{
printf("0\n");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: