1. for sort here
struct POINT{
__int64 a;
__int64 b;
bool operator < (const POINT &p) const {
if(a==0&&b==0) return 0>1;
if(p.a==0&&p.b==0) return 1>0;
__int64 l1 = (a)*(p.b); __int64 l2 = (b)*(p.a);
return l1 < l2;
}
} points[100011];
We define a struct here, just complete the bool operator < (const POINT &p) const{...}, and then call:
sort(points, points+n); //sort the points
2. Second way: qsort
struct POINT{
__int64 a;
__int64 b;
} points[100011];
//define a method of compare here,
//used to sort the points.
//called by qsort method
int compare(const void * p1, const void * p2) {
struct POINT *p3, *p4;
p3 = (struct POINT *)p1;
p4 = (struct POINT *)p2;
__int64 t1, t2;
t1 = (p3->a)*(p4->b);
t2 = (p3->b)*(p4->a);
if(t1<=t2) return -1;
else return 1;
}
Finally
qsort(points,n,sizeof(points[0]),compare);