http://poj.org/problem?id=2007

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<vector>
using namespace std;
#define INF 0xfffffff
#define ESP 1e-8
#define memset(a,b) memset(a,b,sizeof(a))
#define N 2100 struct Point
{
double x,y;
int index;
Point(double x=,double y=):x(x),y(y) {}
Point operator - (const Point &temp)const
{
return Point(x-temp.x,y-temp.y);
}
Point operator + (const Point &temp)const
{
return Point(x+temp.x,y+temp.y);
}
int operator ^(const Point &temp)const ///求叉积
{
double t=(x*temp.y)-(y*temp.x);
if(t>ESP)
return ;
if(fabs(t)<ESP)
return ;
return -;
}
double operator * (const Point &temp)const
{
return x*temp.x+y*temp.y;
}
bool operator == (const Point &temp)const
{
return (x==temp.x)&&(y==temp.y);
}
} p[N]; double dist(Point a1,Point a2)
{
return sqrt((a1-a2)*(a1-a2));
}
int pos=; int cmp(Point a1,Point a2)
{
int t=(a1-p[pos])^(a2-p[pos]);
if(t<) return false;
else
return true;
} int main()
{
int n;
n=;
while(scanf("%lf %lf",&p[n].x,&p[n].y)!=EOF) n++;
pos=; for(int i=; i<n; i++)
{
sort(p+i,p+n,cmp);
pos++;
}
for(int i=; i<n; i++)
printf("(%.0lf,%.0lf)\n",p[i].x,p[i].y);
printf("\n");
return ;
}

Scrambled Polygon--poj2007(极角排序模板)的更多相关文章

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

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

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

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

  3. poj2007极角排序

    裸的极角排序,但是要把0,0放在第一个(话说这题题目真是巨长,废话也多...) #include<map> #include<set> #include<cmath> ...

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

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

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

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

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

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

  7. poj 2007 Scrambled Polygon 极角排序

    /** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...

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

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

  9. Scrambled Polygon POJ - 2007 极角排序

    题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...

随机推荐

  1. 图解GitHub

    转自:http://marklodato.github.io/visual-git-guide/index-zh-cn.html 个人觉得这一篇比一些入门教程更值得看,图解很详细到位,很容易理解其工作 ...

  2. Java格式规范及注释的用法

    /* 需求:演示一个Hello World的Java小程序 思路: 1.定义一个类.因为Java程序都是定义在类中,Java程序都是以类的形式存在的,类的形式其实就是字节码的最终体现 2.定义一个主函 ...

  3. android开发中设置字体

    转自:http://segmentfault.com/q/1010000000494116 http://ryanhoo.github.io/blog/2014/05/05/android-bette ...

  4. Mysql数据库表的迁移和表的复制

    同一台服务器上的,数据库之间的表的迁移: create table db.tablename as select * from db2.tablename; 此sql使用于mysql,从一台服务器上的 ...

  5. yii 和 zend studio 集成

    yii是基于测试驱动的,而zend studio是一个好用的ide.集成就是必须的. 本文适合喜欢使用ide的开发者,vim用户或者文本编辑器使用者请忽略. 本文使用的是最新的zend studio ...

  6. Js 之获取QueryString的几种方法

    一.正则匹配 function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(& ...

  7. iview table 勾选当前行代码 data key _checked: true

    给 data 项设置特殊 key _checked: true 可以默认选中当前项

  8. STL || HDU 1894 String Compare

    如果一个词包含再另一个词的前面(前缀),是一对前缀,求一共有多少对 *解法:STL万岁 #include<string>:https://www.cnblogs.com/SZxiaochu ...

  9. springmvc @RequestParam @RequestBody @PathVariable 等参数绑定注解详解

    简介: handler method 参数绑定常用的注解,我们根据他们处理的Request的不同内容部分分为四类:(主要讲解常用类型) A.处理requet uri 部分(这里指uri templat ...

  10. C字符串指针遇到的问题

    看下面的示例代码: int main() { char *ptr = "GeeksQuiz"; printf("%c\n", *&*&*ptr) ...