POJ 2007 Scrambled Polygon (简单极角排序)
2014-08-28 14:07
561 查看
题目链接
题意 : 对输入的点极角排序
思路 : 极角排序方法
题意 : 对输入的点极角排序
思路 : 极角排序方法
#include <iostream> #include <cmath> #include <stdio.h> #include <algorithm> using namespace std; struct point { double x,y; }p[50],pp; double cross(point a,point b,point c) { return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y) ; } bool cmp(point a,point b) { int cr = cross(a,b,pp) ;//判断顺时针还是逆时针 if(cr > 0) return true ; else if(cr < 0) return false ; } int main() { int cnt = 0; while (scanf("%lf %lf",&p[cnt].x,&p[cnt].y) != EOF) { ++cnt; } pp.x = pp.y = 0 ; sort(p+1,p+cnt,cmp); for (int i = 0 ; i < cnt ; i++) { cout<<"("<<p[i].x<<","<<p[i].y<<")"<<endl; } return 0; }
相关文章推荐
- 简单几何(极角排序) POJ 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon [极角排序]
- POJ 2007 Scrambled Polygon (极角排序)
- POJ 2007 Scrambled Polygon 极角排序
- poj 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon(计算几何 叉积排序啊)
- POJ 2007 Scrambled Polygon 凸包点排序逆时针输出
- POJ 2007 Scrambled Polygon(极角排序)
- poj 2007 Scrambled Polygon 凸包点排序逆时针输出
- POJ 2007 Scrambled Polygon 极角排序
- poj 2007 Scrambled Polygon (极角排序模板题)
- POJ 2007 Scrambled Polygon(点的极角排序)
- poj 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon 极角排序
- POJ 2007 Scrambled Polygon 凸包点排序逆时针输出
- POJ 2007:Scrambled Polygon (极角排序)
- poj 2007 Scrambled Polygon 【极角排序】
- POJ 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon 极角排序
- POJ 2007 Scrambled Polygon [凸包 极角排序]