Allora
codice:
struct DPoint
{
double x, y;
bool left, right; //FALSE DI DEFAULT
};
struct DPoint Points[] = {{2,0.25,0,0}, {3,1,0,0}, {4,0,0,0}, {1,0,0,0}, {3,1,0,0}, {4,0,0,0}};
int compare (const void *v1, const void *v2)
{
return (*((double *)v1) > *((double *)v2));
}
int main(int argc, char* argv[])
{
int i, n = sizeof(Points)/sizeof(DPoint);
for(i=0; i<n; i++)
printf("%f %f\n", Points[i].x, Points[i].y);
qsort(Points, n, sizeof(DPoint), compare);
printf("\n\n");
for(i=0; i<n; i++)
printf("%f %f\n", Points[i].x, Points[i].y);
return 0;
}