zoukankan      html  css  js  c++  java
  • POJ2007+几何+极角排序

    View Code
     1 /*
     2 几何+凸包逆序输出+极角排序
     3 */
     4 #include<stdio.h>
     5 #include<string.h>
     6 #include<stdlib.h>
     7 #include<math.h>
     8 #include<algorithm>
     9 using namespace std;
    10 const int maxn = 55;
    11 const double eps = 1e-8;
    12 struct Point{
    13     double x,y;
    14 };
    15 Point point[ maxn ];
    16 
    17 double xmult( Point sp,Point ep,Point op ){
    18     return ( sp.x-op.x )*( ep.y-op.y )-( sp.y-op.y )*( ep.x-op.x );
    19 }
    20 
    21 int sig( double d ){
    22     if( d>eps ) return 1;
    23     if( d<-eps ) return -1;
    24     return 0;
    25 }
    26 
    27 double dist( Point a,Point b ){
    28     double sum = ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
    29     return sqrt( sum );
    30 }
    31 
    32 int cmp(  Point a, Point b ){
    33     return sig( xmult(a,b,point[0]) )>0;
    34 }
    35 
    36 int main(){
    37     int n = 0;
    38     while( scanf("%lf%lf",&point[ n ].x,&point[ n ].y )!=EOF )
    39         n++;
    40     sort( point+1,point+n,cmp );
    41     for( int i=0;i<n;i++ ){
    42         printf("(%.0lf,%.0lf)\n",point[ i ].x,point[ i ].y);
    43     }
    44     return 0;
    45 }
    keep moving...
  • 相关阅读:
    python中的__init__
    python中的单例模式
    python中闭包和装饰器
    sql多表查询
    configurationChanges
    excludeFromRecents标签
    activity-alias
    meta-data
    launchMode
    Apache ant 配置
  • 原文地址:https://www.cnblogs.com/xxx0624/p/2990326.html
Copyright © 2011-2022 走看看