Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1505382
  • 博文数量: 399
  • 博客积分: 8508
  • 博客等级: 中将
  • 技术积分: 5302
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-14 09:28
个人简介

能力强的人善于解决问题,有智慧的人善于绕过问题。 区别很微妙,小心谨慎做后者。

文章分类

全部博文(399)

文章存档

2018年(3)

2017年(1)

2016年(1)

2015年(69)

2013年(14)

2012年(17)

2011年(12)

2010年(189)

2009年(93)

分类: LINUX

2009-11-30 14:32:25

#include
#include
#include
using namespace std;
class pt
{
public:
    int x,y;
    static pt src;
    pt(){};
    void operator=(pt& a)
    {
        x = a.x;
        y = a.y;
    }
    pt(int a,int b):x(a),y(b){};
};
inline int cross(const pt& a ,const  pt& b , const pt& c)
{
    return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);
}
int dist(const pt& a, const pt& b)
{
    int t = a.x^2+a.y^2-b.x^2-b.y^2;
    return    t;
}
struct cmp
{
    bool operator()(const pt& a,const pt& b)
    {
        int re = cross(a,b,pt::src);
        if(re == 0)
            return  dist(a,pt::src)        return re>0;
    }
};

int graham(vector& m, queue& q, int n)
{
    //找最左下的
    vector::iterator lowest=m.begin(),it;
    for(it=m.begin()+1; it!=m.end();it++)        
        if(it->yy  || it->y==lowest->y && it->xx)
            lowest = it;
    iter_swap(m.begin(),lowest);
    pt::src=m[0];    
    sort(m.begin()+1,m.end(),cmp());
    q.push(m[0]); //坐标原点
    int i = 1;
    while(i    {
        while(i=0)
            i++;
        q.push(m[i++]);
    }
};
pt pt::src(0,0);
main()
{
    
}
阅读(1763) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~