#include #include #define MAX 100000 struct bod { int x, y; }; int compare1(const void* a, const void* b) { if( ((const bod*)a)->x > ((const bod*)b)->x ) return 1; if (((bod*)a)->x == ((bod*)b)->x ) { if ( ((bod*)a)->y > ((bod*)b)->y ){ return 1; } else if (((bod*)a)->y == ((bod*)b)->y ){ return 0; } else {return -1; } } else { return -1; } } int compare2(const void* a, const void* b) { if( ((bod*)a)->y > ((bod*)b)->y ) return 1; if (((bod*)a)->y == ((bod*)b)->y ) { if( ((bod*)a)->x > ((bod*)b)->x ){ return 1; } else if (( (bod*)a)->x == ((bod*)b)->x ){ return 0; } else {return -1; }} else { return -1; } } int soucet; int main() { bod pole[MAX]; int i, j, count; while(scanf("%d", &count), count) { soucet = 0; for(i = 0; i < count; i++) scanf("%d %d", &pole[i].x, &pole[i].y); qsort(pole, count, sizeof(bod), compare1); for (i=0; i