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

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 6701   Accepted: 3185

Description

A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any vertex of a closed polygon and traverses each bounding line segment exactly once, one comes back to the starting vertex.

A closed polygon is called convex if the line segment joining any two points of the polygon lies in the polygon. Figure 1 shows a closed polygon which is convex and one which is not convex. (Informally, a closed polygon is convex if its border doesn't have any "dents".) 

The subject of this problem is a closed convex polygon in the coordinate plane, one of whose vertices is the origin (x = 0, y = 0). Figure 2 shows an example. Such a polygon will have two properties significant for this problem.

The first property is that the vertices of the polygon will be confined to three or fewer of the four quadrants of the coordinate plane. In the example shown in Figure 2, none of the vertices are in the second quadrant (where x < 0, y > 0).

To describe the second property, suppose you "take a trip" around the polygon: start at (0, 0), visit all other vertices exactly once, and arrive at (0, 0). As you visit each vertex (other than (0, 0)), draw the diagonal that connects the current vertex with (0, 0), and calculate the slope of this diagonal. Then, within each quadrant, the slopes of these diagonals will form a decreasing or increasing sequence of numbers, i.e., they will be sorted. Figure 3 illustrates this point. 
 

Input

The input lists the vertices of a closed convex polygon in the plane. The number of lines in the input will be at least three but no more than 50. Each line contains the x and y coordinates of one vertex. Each x and y coordinate is an integer in the range -999..999. The vertex on the first line of the input file will be the origin, i.e., x = 0 and y = 0. Otherwise, the vertices may be in a scrambled order. Except for the origin, no vertex will be on the x-axis or the y-axis. No three vertices are colinear.

Output

The output lists the vertices of the given polygon, one vertex per line. Each vertex from the input appears exactly once in the output. The origin (0,0) is the vertex on the first line of the output. The order of vertices in the output will determine a trip taken along the polygon's border, in the counterclockwise direction. The output format for each vertex is (x,y) as shown below.

Sample Input

  1. 0 0
  2. 70 -50
  3. 60 30
  4. -30 -50
  5. 80 20
  6. 50 -60
  7. 90 -20
  8. -30 -40
  9. -10 -60
  10. 90 10

Sample Output

  1. (0,0)
  2. (-30,-40)
  3. (-30,-50)
  4. (-10,-60)
  5. (50,-60)
  6. (70,-50)
  7. (90,-20)
  8. (90,10)
  9. (80,20)
  10. (60,30)

Source

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

这题,,,,,这什么玩意啊

推荐个网站:http://www.cnblogs.com/devtang/archive/2012/02/01/2334977.html

  1. 《叉积排序,也就是可以排180度以内的,超出就会出错,
  2. 因为正弦函数在180内为正数,180360为负数。》
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <math.h>
  7.  
  8. #define MAXX 105
  9.  
  10. using namespace std;
  11.  
  12. typedef struct point
  13. {
  14. int x,y;
  15. }point;
  16. typedef struct line
  17. {
  18. point st,ed;
  19. }beline;
  20.  
  21. int crossProduct(point a,point b,point c)
  22. {
  23. return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x);
  24. }
  25.  
  26. double Dist(point a,point b)
  27. {
  28. return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  29. }
  30.  
  31. point c[MAXX];
  32. point stk[MAXX];
  33. int top;
  34. bool cmp(point a,point b)
  35. {
  36. int len=crossProduct(c[],a,b);
  37. if(len == )
  38. return Dist(c[],a)<Dist(c[],b);
  39. else
  40. return len<;
  41. }
  42.  
  43. int main()
  44. {
  45. int i,j,k,t,x,y;
  46. i=;
  47. while(scanf("%d%d",&x,&y)!=EOF)
  48. {
  49. c[i].x=x;
  50. c[i].y=y;
  51. i++;
  52. }
  53. sort(c+,c+i,cmp);
  54. for(int j=; j<i; j++)
  55. printf("(%d,%d)\n",c[j].x,c[j].y);
  56. }

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

  1. poj 2007 Scrambled Polygon 极角排序

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

  2. POJ 2007 Scrambled Polygon 极角序 水

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

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

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

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

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

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

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

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

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

  7. ●POJ 2007 Scrambled Polygon

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

  8. POJ 2007 Scrambled Polygon 凸包

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7214   Accepted: 3445 ...

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

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

随机推荐

  1. linux设备驱动归纳总结(三):6.poll和sellct【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-61749.html linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxx ...

  2. 2015.01.15(android AsyncTask)

    参考网址:http://www.cnblogs.com/devinzhang/archive/2012/02/13/2350070.html /* * Params 启动任务执行的输入参数,比如HTT ...

  3. SuperSocket架构设计示意图【转】

    转自:http://docs.supersocket.net/v1-6/zh-CN/Architecture-Diagrams 中文(中国)Toggle Dropdown v1.6Toggle Dro ...

  4. Java中的HashMap 浅析

    在Java的集合框架中,HashSet,HashMap是用的比较多的一种,顺序结构的ArrayList.LinkedList这种也比较多,而像那几个线程同步的容器就用的比较少,像Vector和Hash ...

  5. Axure简介

    Axure RP(Rapid Prototyping快速原型) 是美国公司Axure Software Solution公司旗舰产品,是一个专业的快速原型设计工具,让负责定义需求和规格.设计功能和界面 ...

  6. JavaEE基础(二十二)/IO流

    1.IO流(序列流) 1.什么是序列流 序列流可以把多个字节输入流整合成一个, 从序列流中读取数据时, 将从被整合的第一个流开始读, 读完一个之后继续读第二个, 以此类推. 2.使用方式 整合两个: ...

  7. 使用mysqlbinlog server远程备份binlog的脚本

    #注意,备份机到远程mysql服务器需要免密钥登录,此脚本放到计划任务中每五分钟执行一次,避免mysqlbinlog server进程长时间挂掉无人知晓   cat backup_binlog.sh ...

  8. 简单选择排序(Java)

    简单选择排序: 每一趟在整个记录中找到最小的那个作为有序序列的第i个记录. class SelectSort{ public void p(int[] a){ for(int i=0;i<a.l ...

  9. extjs 中动态给gridpanel 复选框赋值

    最近在搞extjs时需要动态根据数据给gridpanel的复选框赋值 网上看了很多 ,多不行,最后找到一个好使的方法 如下: RBACformPanel.getSelectionModel().sel ...

  10. poj2482 Stars in Your Window

    此题可用线段树或静态二叉树来做. 考虑用线段树: 很容易想到先限定矩形横轴范围再考虑在此纵轴上矩形内物品总价值的最大值. 那么枚举矩形横轴的复杂度是O(n)的,考虑如何快速获取纵轴上的最大值. 我们不 ...