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. 在Apache服务器中禁用option

    在apache禁止 http OPTIONS方法. apache disable http OPTIONS method 2013-04-17 09:27 4050人阅读 评论(1) 收藏 举报  分 ...

  2. fork后子进程从哪里开始执行

    子进程和父进程都从调用fork函数的下一条语句开始执行

  3. JS:输出9*9乘法表

    <html> <head> <title>9*9 multiplication table</title> </head> <body ...

  4. dropdb - 删除一个现有 PostgreSQL 数据库

    SYNOPSIS dropdb [ option...] dbname DESCRIPTION 描述 dropdb 删除一个现有 PostgreSQL 数据库. 执行这条命令的人必须是数据库超级用户, ...

  5. DECLARE - 定义一个游标

    SYNOPSIS DECLARE name [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ...

  6. JDK 5 ~ 11 新特性倾情整理

    为了大家对JDK有一个全面的了解,下面我为大家整理了JDK5~11的所有关键新特性! 先看一下JDK的版本迭代图: 注:   OpenJDK和JDK区别  GPL协议通用性公开许可证(General ...

  7. input_shape { dim: 1 dim: 3 dim: 224 dim: 224 }

    http://blog.csdn.net/u010417185/article/details/52619593

  8. treetable

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. python之bool (布尔值)

    用途: ​ 判断真假 识记: 空的字符串是False,非空的就是True 0 是False,非0的都是True 格式: True False 布尔值转换成字符串: print(type(str(Tru ...

  10. Springboot 配置文件与对象之间进行映射之@ConfigurationProperties

    一.将配置文件与实体类绑定1.1.将yaml配置文件的属性映射到Javabean中1.1.1.yaml配置文件注意:键值对的语法,键:之后必须要有空格 1.1.2.Javabean 定义注意:java ...