/**
极角排序输出,,,
主要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. Ubuntu 13.04 小米2S连接Eclipse真机调试

    最近想继续将自己以前的一些Android程序代码进行改进和优化,遂将以前的代码在windows下导入eclipse工程,谁知导入后便eclipse假死,甚至windows资源管理器也动弹不得,诡异的是 ...

  2. iOS_词典阵列 按key分组和排序

    // // main.m // SortGroup // // Created by beyond on 14-10-26. // Copyright (c) 2014年 beyond.com All ...

  3. 性能优化工具---vmstat

    作用: 报告关于内核线程.虚拟内存.磁盘.陷阱和 CPU 活动的统计信息 参数: 通过两个数字参数来完成的,第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数 显示说明: 第一行数据反映开 ...

  4. Jar包下载地址

    Download Apache log4j 1.2.17下载: http://logging.apache.org/log4j/1.2/download.html jsoup http://jsoup ...

  5. jQuery获取Select选择的Text(非表单元素)和 Value(表单元素)(转)

    jQuery获取Select选择的Text和Value: 语法解释: . $("#select_id").change(function(){//code...}); //为Sel ...

  6. 微信支付 v 3.3.6

    文字说明: 前提:注册.申请服务号,开通微信支付. 涉及到的参数:AppId.AppSecret.原始ID(自动回复).mch_id(商户号).Key(商户密钥:自己设定.) 统一规范: 要求 认证方 ...

  7. 五毛的cocos2d-x学习笔记08-动画

    一个例子就够了,单击文本标签,执行动画.我也是小白,写这个demo的时候遇到了问题,单击文本标签游戏就死掉了.今天为了解决这个问题也是一晚没睡,到学习群里问大神,经过大神的指点解决了问题.原来是Ani ...

  8. fork进程函数总结

    学习链接: http://blog.csdn.net/jason314/article/details/5640969 http://coolshell.cn/articles/7965.html 搜 ...

  9. JSP page include taglib

    page include taglib 语法:<%@ 指令名称 属性=值 属性=值 -%> ------------------- page 1.language 默认值java 2.ex ...

  10. C++中的unordered_map

    1.简介 随着C++0x标准的确立,C++的标准库中也终于有了hash table这个东西.很久以来,STL中都只提供<map>作为存放对应关系的容器,内部通常用红黑树实现,据说原因是二叉 ...