|
|
вернуться в форумnow its me... HELP ME Послано Edans 30 апр 2002 09:01 somebody see a mistake? #define MAXINT 2000000000 #include<stdio.h> #include<math.h> #include<stdlib.h> typedef struct{ int x,y; int ID; double ang; }ponto_t; ponto_t tb[10000]; int sort( const void *a, const void *b){ ponto_t* ta = (ponto_t*)a; ponto_t* tb = (ponto_t*)b; if ((ta->x==0) && (ta->y==0)) return -1; if ((tb->x==0) && (tb->y==0)) return 1; return (ta->x*tb->y - tb->x*ta->y)>0?1:-1; } int main(){ #ifndef ONLINE_JUDGE freopen("1207.in","r",stdin); freopen("1207.out","w",stdout); #endif int n,x=MAXINT,themin=0,k; scanf("%d",&n); for(k=0;k<n;k++){ scanf("%d %d",&(tb[k].x),&(tb[k].y)); tb[k].ID=k+1; if (tb[k].x<x){ x=tb[k].x; themin=k; } } for(k=0;k<n;k++){ tb[k].x-=tb[themin].x; tb[k].y-=tb[themin].y; } qsort(tb,n,sizeof(ponto_t),sort); printf("%d %d",tb[0].ID,tb[n/2].ID); return 0; } |
|
|