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代码:
思路:
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; }
相关文章推荐
- mycat分布式mysql中间件(分片规则)
- [学习笔记]MFC 中的CDC类
- activiti-modeler 工作流设计器代码分析
- java web环境搭建
- CSS布局那点事儿
- WCF上传文件
- Html+Css 链接状态变换的单图片实现(精通CSS高级WEB解决方案)读书笔记
- 第六课:键盘和鼠标
- 解决5.0以上通知栏图标变白
- CInt
- 重拾c语言——宏定义的预处理
- OpenCV学习04
- Android中使用TextView实现图文混排的方法
- 网站开发环境的配置
- EFI基本概念之FV
- android 自定义下拉刷新动画效果
- OpenCV学习03
- Extjs 删除输入内容前后空格
- 如何入门 Python 爬虫?
- ehcache的简单使用