|
|
back to boardCommon BoardHelp whith 1111. I don't know where mistake Posted by Sam 24 Sep 2001 13:08 Help me!!!!?????? My code is: var x1,y1,x2,y2:array[1..110]of comp; d:array[1..110]of comp; a:array[1..110]of integer; p:integer; i,j,n:integer; pr:comp; x,y:comp; function ras(x1,y1,x2,y2:comp):comp; begin if(x>=x1)and(x<=x2) then begin if (y>=y1)and(y<=y2) then begin ras:=0; end else begin if y<y1 then ras:=sqr(y1-y) else ras:=sqr(y-y2); end; end else begin if (y>=y1)and(y<=y2) then begin if x<x1 then ras:=sqr(x1-x) else ras:=sqr(x-x2); end else begin if(x<x1)and(y<y1) then ras:=sqr(x1-x)+sqr(y1-y) else if(x<x1)and(y>y2) then ras:=sqr(x1-x)+sqr(y2- y) else if(x>x2)and(y<y1) then ras:=sqr(x2-x)+sqr(y1- y) else if(x>x2)and(y>y2) then ras:=sqr(x2-x)+sqr(y2- y) else begin x:=x/0; end; end; end; end; begin readln(n); for i:=1 to n do begin readln(x1[i],y1[i],x2[i],y2[i]); if x1[i]>x2[i] then begin pr:=x1[i]; x1[i]:=x2[i]; x2[i]:=pr; end; if y1[i]>y2[i] then begin pr:=y1[i]; y1[i]:=y2[i]; y2[i]:=pr; end; a[i]:=i; end; read(x,y); for i:=1 to n do d[i]:=ras(x1[i],y1[i],x2[i],y2[i]); for i:=1 to n-1 do for j:=i+1 to n do if (d[i]>d[j])or((d[i]=d[j])and(a[i]>a[j])) then begin p:=a[i]; a[i]:=a[j]; a[j]:=p; pr:=d[i]; d[i]:=d[j]; d[j]:=pr; end; for i:=1 to n do write(a[i],' '); end. Maybe I can help........ Hi, Well, I haven't taken a look at your source code, but I have to ask you the following- do you consider that rectangles may have sides which are not parallel to the ordinate and abscissas? I am writing the solution now, and I think that there must be some tests which catch exactly this mistake. Am I right, Jivko? Maybe I can help........ Hi, Well, I haven't taken a look at your source code, but I have to ask you the following- do you consider that rectangles may have sides which are not parallel to the ordinate and abscissas? I am writing the solution now, and I think that there must be some tests which catch exactly this mistake. Am I right, Jivko? Re: Maybe I can help........ I won't answer this, but I put a hint in the problem statement(that wasn't available on the real compo) which should answer your question. Jivko,could you show me your problem? Posted by Come on 27 Sep 2001 17:30 |
|
|