Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
顶个老贴In Reply To:map 我崩溃了,为啥有的查不到呢 Posted by:nuanran at 2008-10-28 02:47:55 struct pointCmp { bool operator() (const Point p1,const Point p2) const { if(p1.x==p2.x) return p1.y-p2.y; return p1.x-p2.x; } }; 这里有问题, stl 中的比较器与 qsort所需要的不同. qsort需要的是能判断<,>,=三种关系的比较器,因此返回值是int, 以正负零来区分 而stl中的sort与map等需要的是<比较器,只需要判断是否小于, 以true/false区分 所以这里可以改成 struct pointCmp { bool operator() (const Point p1,const Point p2) const { if(p1.x==p2.x) return p1.y<p2.y; return p1.x<p2.x; } }; Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator