|
|
вернуться в форумWhat happen if the problem change Squares to Rectangle, I have submit this code and i got WA ,I heard that it's different from the rectangle, what about it??? Послано Badd 10 янв 2002 09:23 for loop:=1 to n do begin if px in [dat[loop].x1..dat[loop].x2] then begin if py in [dat[loop].y1..dat[loop].y2] then begin dat[loop].nearx:=px; dat[loop].neary:=py; end else if py<dat[loop].y1 then begin dat[loop].nearx:=px; dat[loop].neary:=dat[loop].y1; end else if py>dat[loop].y2 then begin dat[loop].nearx:=px; dat[loop].neary:=dat[loop].y2; end; end else if py in [dat[loop].y1..dat[loop].y2] then begin if px<dat[loop].x1 then begin dat[loop].neary:=py; dat[loop].nearx:=dat[loop].x1; end else if px>dat[loop].x2 then begin dat[loop].neary:=py; dat[loop].nearx:=dat[loop].x2; end; end else if py<dat[loop].y1 then begin if px<dat[loop].x1 then begin dat[loop].nearx:=dat[loop].x1; dat[loop].neary:=dat[loop].y1; end else if px>dat[loop].x2 then begin dat[loop].nearx:=dat[loop].x2; dat[loop].neary:=dat[loop].y1; end end else if py>dat[loop].y2 then begin if px<dat[loop].x1 then begin dat[loop].nearx:=dat[loop].x1; dat[loop].neary:=dat[loop].y2; end else if px>dat[loop].x2 then begin dat[loop].nearx:=dat[loop].x2; dat[loop].neary:=dat[loop].y2; end end; end; and then i check the distance from each dat[i].nearx,neary to point The square could have these coordinates : (0,0), (1,1), (0,2), (-1,1). Good luck! (-) |
|
|