/**
极角排序输出,,,
主要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. MapReduce实现矩阵相乘

    矩阵相乘能够查看百度百科的解释http://baike.baidu.com/view/2455255.htm?fr=aladdin 有a和b两个矩阵 a:                1   2   ...

  2. nodejs在服务器上运行

     nodejs运行之后,关掉链接,网站运行就会断开,需要安装forever,后台执行. 安装方法如下(在windows和Linux下都能运行)://forever的安装: npm install fo ...

  3. vs 中 vim vax 快捷键

    高效率移动 在插入模式之外 基本上来说,你应该尽可能少的呆在插入模式里面,因为在插入模式里面VIM就像一个“哑巴”编辑器一样.很多新手都会一直呆在插入模式里面,因为这样易于使用.但VIM的强大之处在于 ...

  4. Struts学习之文件上传

    * 单文件上传:        * 在动作类action中声明相关属性:            * 在动作类action中,要声明与页面中表单name属性同名的属性,同名的属性的类型是File类型:  ...

  5. 搭建单节点Hadoop应用环境

    虚拟机: VirtualBox 5 Server操作系统: Ubuntu Server 14.04.3 LTS 如果对虚拟机空间和性能不做考虑, 且不习惯用Linux命令, 你也可以使用Ubuntu ...

  6. Android 应用接入广点通统计API 方案

    官方给你参考文档,很扯淡,是c++和python脚本: 安卓java代码接入如下: package com.edaixi.util; import java.io.UnsupportedEncodin ...

  7. CSS完美兼容IE6/IE7/IE8/IE9/IE10的通用方法

    关于CSS对各个浏览器兼容已经是老生常谈的问题了, 网络上的教程遍地都是.以下内容没有太多新颖, 纯属个人总结, 希望能对初学者有一定的帮助. 一.CSS HACK 以下两种方法几乎能解决现今所有HA ...

  8. while 、do...while 、for

    1.while 特点:只有条件成立才会执行循环体. while陷阱: while(条件);即直接加分号 2.do while 特点:一定会执行一次循环体 3.for语句 l   初始化等可以是多句(把 ...

  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. XML实例入门1

    虽然网上会有XML入门或者多少天教会XML,一般都是从普通的功能概念开始啰嗦,个人还是比较喜欢从实例开始,遇到不懂直接查(不过这次选了一个比较难得例子,研究了好久^_^).刚开始看了一个vc6.0XM ...