题目链接

题意 : 对输入的点极角排序

思路 : 极角排序方法

#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm> using namespace std; struct point
{
double x,y;
}p[],pp;
double cross(point a,point b,point c)
{
return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y) ;
}
bool cmp(point a,point b)
{
int cr = cross(a,b,pp) ;//判断顺时针还是逆时针
if(cr > ) return true ;
else if(cr < ) return false ;
}
int main()
{
int cnt = ;
while (scanf("%lf %lf",&p[cnt].x,&p[cnt].y) != EOF)
{
++cnt;
}
pp.x = pp.y = ;
sort(p+,p+cnt,cmp);
for (int i = ; i < cnt ; i++)
{
cout<<"("<<p[i].x<<","<<p[i].y<<")"<<endl;
}
return ;
}

POJ 2007 Scrambled Polygon (简单极角排序)的更多相关文章

  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. POJ 2007 Scrambled Polygon 凸包点排序逆时针输出

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

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

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

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

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

  6. poj 2007 Scrambled Polygon 极角排序

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

  7. POJ 2007 Scrambled Polygon 极角序 水

    LINK 题意:给出一个简单多边形,按极角序输出其坐标. 思路:水题.对任意两点求叉积正负判断相对位置,为0则按长度排序 /** @Date : 2017-07-13 16:46:17 * @File ...

  8. ●POJ 2007 Scrambled Polygon

    题链: http://poj.org/problem?id=2007 题解: 计算几何,极角排序 按样例来说,应该就是要把凸包上的i点按 第三像限-第四像限-第一像限-第二像限 的顺序输出. 按 叉积 ...

  9. poj 2007 凸包构造和极角排序输出(模板题)

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10841   Accepted: 508 ...

随机推荐

  1. android保存图片的方式

    Android中保存图片的两种方式 第一种是保存到数据库: 1.保存到数据库: 2.从数据库读取: 二是以图片格式保存到本地 1. A.声明tempFile以保存到指定路径: B.保存到tempFil ...

  2. 今天开始应该使用 5 个JavaScript调试技巧

    原文:5 Javascript debugging tips you’ll start using today 我之前使用过用 printf debugging,自此之后我用这种方法似乎总能更快地解决 ...

  3. 如何在ios 系统 中抓包??

    为了实现在ios系统上抓包,如下步骤: 1,设备越狱 2,在cydia-软件源-设置中改为开发者,否则有些deb搜索不到 安装如下软件:OpenSSH,OpenSSL,wget (下载工具) Apti ...

  4. 常用gradle命令

    1.build.gradle ext { profile = "dev" tag='web' if (project.hasProperty('pro')) { temp = pr ...

  5. MongoDB学习笔记-数据库命令

    概念 数据库命令(database command)是一种非常特殊类型的查询.文档的创建.更新.删除及查询都属于数据库命令的范畴,它还包含管理性的任务(比如关闭服务器和克隆数据库).统计数据及执行聚合 ...

  6. Android实现SharePreferences和AutoCompletedTextView

    Android实现SharePreferences和AutoCompletedTextView 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 ...

  7. datawindow直接导入导出xml

    long dwcontrol.ImportFile ( XML!, filename ) dw_.Modify("DataWindow.Export.XML.UseTemplate = 't ...

  8. MATLAB GUI程序设计中ListBox控件在运行期间消失的原因及解决方法

    在运行期间,ListBox控件突然消失,同时给出如下错误提示: Warning: single-selection listbox control requires that Value be an ...

  9. angularjs resources

    http://tutorials.jenkov.com/angularjs/watch-digest-apply.html http://angular-tips.com/blog/2013/08/w ...

  10. VBS数组函数学习实例分析

    Array 函数 返回包含数组的Variant. Array(arglist) 参数:arglist是赋给包含在Variant中的数组元素的值的列表(用逗号分隔).如果没有指定此参数,则将会创建零长度 ...