/**
极角排序输出,,,
主要atan2(y,x) 容易失精度,,用
bool cmp(point a,point b){
5 if(cross(a-tmp,b-tmp)>0)
6 return 1;
7 if(cross(a-tmp,b-tmp)==0)
8 return length(a-tmp)<length(b-tmp);
9 return 0;
10 }
**/
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; struct point {
double x,y;
point (double x=,double y=):x(x),y(y){}
};
point p[];
point tmp;
typedef point Vector;
Vector operator - (point a,point b){
return Vector (a.x-b.x,a.y-b.y);
}
double angle(Vector v){
return atan2(v.y,v.x);
}
double length(Vector v){
return sqrt(v.x*v.x+v.y*v.y);
} double cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
bool cmp(point a,point b){
if(cross(a-tmp,b-tmp)>)
return ;
if(cross(a-tmp,b-tmp)==)
return length(a-tmp)<length(b-tmp);
return ;
} int main()
{
int cnt =;
double x1,y1;
cin>>tmp.x>>tmp.y;
while(cin>>x1>>y1){
p[cnt].x = x1;
p[cnt].y = y1;
cnt++;
}
sort(p,p+cnt,cmp);
cout<<"("<<tmp.x<<","<<tmp.y<<")"<<endl;
for(int i=;i<cnt;i++)
cout<<"("<<p[i].x<<","<<p[i].y<<")"<<endl;
return ;
}

poj 2007 Scrambled Polygon 极角排序的更多相关文章

  1. POJ 2007 Scrambled Polygon 极角序 水

    LINK 题意:给出一个简单多边形,按极角序输出其坐标. 思路:水题.对任意两点求叉积正负判断相对位置,为0则按长度排序 /** @Date : 2017-07-13 16:46:17 * @File ...

  2. POJ 2007 Scrambled Polygon [凸包 极角排序]

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 ...

  3. 简单几何(极角排序) POJ 2007 Scrambled Polygon

    题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...

  4. POJ 2007 Scrambled Polygon (简单极角排序)

    题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...

  5. POJ 2007 Scrambled Polygon(简单极角排序)

    水题,根本不用凸包,就是一简单的极角排序. 叉乘<0,逆时针. #include <iostream> #include <cstdio> #include <cs ...

  6. ●POJ 2007 Scrambled Polygon

    题链: http://poj.org/problem?id=2007 题解: 计算几何,极角排序 按样例来说,应该就是要把凸包上的i点按 第三像限-第四像限-第一像限-第二像限 的顺序输出. 按 叉积 ...

  7. POJ 2007 Scrambled Polygon 凸包

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7214   Accepted: 3445 ...

  8. poj 2007 Scrambled Polygon(极角排序)

    http://poj.org/problem?id=2007 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6701   A ...

  9. POJ 2007 Scrambled Polygon 凸包点排序逆时针输出

    题意:如题 用Graham,直接就能得到逆时针的凸包,找到原点输出就行了,赤果果的水题- 代码: /* * Author: illuz <iilluzen[at]gmail.com> * ...

随机推荐

  1. poj2486 Apple Tree (树形dp)

    题意:有一颗苹果树,树上的u节点上有num[u]个苹果,树根为1号节点,囧king从根开始走,没走到一个节点就把接点上的苹果吃光,问囧king在不超过k步的情况下最多吃多少个苹果. 解题思路:处理出两 ...

  2. BoundsChecker使用

      转载:http://www.cnitblog.com/qiuyangzh/archive/2005/07/14/975.html 1 前言 我在本文中具体介绍了測试工具NuMega Devpart ...

  3. 无废话ubuntu 13.4w文件共享配置

    目标:实现windows和linux混合组成的操作 系统中可以共享文件,并可以通过机器名互相访问 安装文件共享服务 0.更改本机主机名,修改 /etc/hostname文件和/etc/hosts文件中 ...

  4. Maven真——聚合和继承(于)

    依赖管理 我们谈论继承一个dependencies因素,我们非常easy这个特性被认为是适用于accout-parent于. 子模块account-email和account-persist同一时候依 ...

  5. openstack之nova启动实例过程

    概述: 启动一个实例包含以下步骤: API server:处理用户请求并转发至cloud controller cloud controller:处理计算节点.网络控制.api server 以及sc ...

  6. C# 文件帮助类

    using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; us ...

  7. shell命令基础

    1.修改密码 使用 passwd 命令修改密码. 该命令如果在 root 用户下执行,则修改的是 root 用户的密码. 2.获取帮助 使用 ls --help 命令获取帮助. [zhanghuiju ...

  8. vs2012C#编程环境设置智能提示

    vs2012 智能提示和  显示行号的问题 路径为    菜单里 工具-->选项-->文本编辑器-->C#  如图所示 自动列出成员就是 vs里面的智能提示 行号就会显示所写代码的行 ...

  9. (Problem 39)Integer right triangles

    If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exact ...

  10. this .运算符 和 [] 运算符

    首先看这个  这两个运行结果是不一样的 前两个是3  后面是10 var length = 10; var arr = [function(){console.log(this.length);},2 ...