#include #include #include int pole[301][301]; int index[301][301]; int porus_[301]; int index2[301]; int x[301], y[301]; #define DBG(a...) void p(int x,int y) { printf("(%d,%d)",x,y); } int compar(int *i, int *j) { if (x[*i] < x[*j]) return -1; else if (x[*i] > x[*j]) return 1; if (y[*i] < y[*j]) return -1; return 1; } int comparX(int *i, int *j) { if (x[*i] < x[*j]) return -1; else if (x[*i] > x[*j]) return 1; if (y[*i] < y[*j]) return -1; else if (y[*i] > y[*j]) return 1; return 0; } int compar2(int *i, int *j) { int c1, c2; int res; res = comparX(&(index[*i][0]), &(index[*j][0])); if (!res) res = comparX(&(index[*i][1]), &(index[*j][1])); return res; } int main(void) { int c_ulohy = 0; int N, i, j, porus, cpor, k; for (;;) { c_ulohy ++; DBG("Uloha %d\n", c_ulohy); N = 0; do { scanf("%d %d",&x[N], &y[N]); N ++; } while(x[N-1] || y[N-1]); if (N == 1) break; N--; if (N < 3) { printf("Smernice byla dodrzena.\n"); DBG("Malo lidi!\n"); continue; } cpor = 0; for (i=0; i < N-2; i++) { for (j = i+1; j < N-1; j++) { if (pole[i][j] == c_ulohy) continue; porus = 0; for (k = j+1; k< N; k++) { if ((x[i]-x[j])*(y[i]-y[k]) == (x[i]-x[k])*(y[i]-y[j])) { index2[cpor] = cpor; if (porus == 0) { index[cpor][porus++] = i; index[cpor][porus++] = j; } index[cpor][porus++]=k; pole[i][k] = c_ulohy; pole[j][k] = c_ulohy; } } if (porus != 0) { int i; qsort(index[cpor], porus, sizeof(int), compar); porus_[cpor] = porus; cpor++; /* for (i=0; i