structTPoint
{
doublex,y;
}ply[N];
bool cmpx(TPoint a,TPoint b){return a.x<b.x;}
sort(ply,ply+n,cmpx); 求这两个函数分别的作用.特别是bool cmpx函数究竟是怎么运作的???
如果能帮我将上面的bool cmpx函数改写成 类似以下代码 的形式,问题应该就解决了~~~
麻烦众大神解救~
int cmp( const POINT &a, const POINT &b ){
if( a.x < b.x )
return 1;
else
if( a.x == b.x ){
if( a.y < b.y )
return 1;
else
return 0;
}
else
return 0;
}
sort(a,a+n,cmp);
//是先按x升序排序,若x值相等则按y升序排
弑天下
相关分类