/**
极角排序输出,,,
主要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. B树、B-树、B+树、B*树都是什么(转)

    B树        即二叉搜索树:        1.所有非叶子结点至多拥有两个儿子(Left和Right):        2.所有结点存储一个关键字:        3.非叶子结点的左指针指向小于 ...

  2. System.Data.SQLite兼容32位和64位问题

    SQLite版本分的很详细,本机是64位在32位会出现问题,经过搜索找到解决方案. 这是我以前写的32位在我现在的机子上的运行报错. 类似这样的. 将当前说明文档的目录下的x64.x86目录和Syst ...

  3. sass 语法实例

    sass基本语法 1.定义一个变量,变量定义以$开头,以冒号分隔开. $blue:#1875e7; div{ color:$blue; } 编译之后的css代码: div { color: #1875 ...

  4. iis 目录枚举文件枚举解决方案

    1.关闭windows的8.3格式功能. 修改注册表键值: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem 修改NtfsD ...

  5. SGU 134.Centroid( 树形dp )

    一道入门树dp, 求一棵树的重心...我是有多无聊去写这种题...傻X题写了也没啥卵用以后还是少写好.. ----------------------------------------------- ...

  6. leetcode find median sorted arrays python

    # @link http://www.cnblogs.com/zuoyuan/p/3759682.html class Solution(object): def findMedianSortedAr ...

  7. SSL是啥?

    SSL(Secure Socket Layer) 的主要作用是验证客户端与服务器的有效性,并在数据传输前,就进行加密,避免在传输过程中被窃取,同时亦可保证数据的完整性,确保数据在传输过程中不被篡改,以 ...

  8. python parse命令行参数

    #!/usr/bin/env python import sys def main(argv): for arg in argv: print arg if __name__ == '__main__ ...

  9. Decorators and Wrappers in Python

    python代码一贯以优雅,简洁著称,而有时侯反而会让人难以理解,比如说wrapper(或者说decorator),这种方式提高了代码的可重用性,使用起来更简洁方便. 举个例子,比如WebApp常用的 ...

  10. MySQL学习系列一---命令行连接mysql和执行sql文件

    1.命令行连接mysql #mysql -h(主机) -u(用户名) -p (数据库名) mysql -hlocalhost -uroot -p testdb Enter password: **** ...