All pastes #59227 Raw Edit

ghostbusters

public c v1 · immutable
#59227 ·published 2006-05-27 17:22 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>struct point{    int x;    int y;    int numer;    int kto;    int zajety;} PUNKTY[200000];struct point *elementy[200000];void connect(int n);int compare(const void *arg1, const void *arg2){    struct point *Arg1=(struct point*)arg1;    struct point *Arg2=(struct point*)arg2;    return((Arg2->x - elementy[0]->x)*(Arg1->y - elementy[0]->y)          -(Arg1->x - elementy[0]->x)*(Arg2->y - elementy[0]->y));}int main(){    int n,N,i, numer=1;    int smallest=0;    scanf("%d\n", &n);    for(i=0; i<n; i++)    {        scanf("%d %d\n", &PUNKTY[i].x, &PUNKTY[i].y); /*pogromcy duchow*/        PUNKTY[i].numer=numer++;        PUNKTY[i].kto=1;        elementy[i]=&PUNKTY[i];        if(elementy[i]->y < elementy[smallest]->y)        {            smallest=i;        }        else if(elementy[i]->y == elementy[smallest]->y && elementy[i]->x < elementy[smallest]->x)        {            smallest=i;        }    }    N=2*n;    numer=1;    for(; i<N; i++)    {        scanf("%d %d\n", &PUNKTY[i].x, &PUNKTY[i].y); /*duchy*/        PUNKTY[i].numer=numer++;        PUNKTY[i].kto=0;        elementy[i]=&PUNKTY[i];        if(elementy[i]->y < elementy[smallest]->y)        {            smallest=i;        }        else if(elementy[i]->y == elementy[smallest]->y && elementy[i]->x < elementy[smallest]->x)        {            smallest=i;        }    }    for(i=0; i<N; i++)    {        printf("%d %d %d %d", PUNKTY[i].x, PUNKTY[i].y, PUNKTY[i].numer, PUNKTY[i].zajety);        if(PUNKTY[i].kto==1) printf(" pogromca\n");        else printf(" duch\n");    }    /*najmniejszy el. jako pierwszy*/    elementy[0]=&PUNKTY[smallest];    elementy[smallest]=&PUNKTY[0];    for(i=0; i<N; i++)    {        printf("%d %d\n", elementy[i]->x, elementy[i]->y);    }    printf("sortuj\n");    qsort(elementy+1, N-1, sizeof(struct point *), &compare);    for(i=0; i<N; i++)    {        printf("%d %d\n", elementy[i]->x, elementy[i]->y);    }    /*laczenie*/    connect(N);    return 0;}void connect(int N){    if(N==2) printf("1");    else printf("bla bla bla");}