Need help. Look over my code or give some tests please. Please help me, look over my code, I'll be thankfull to anyone who will find mistake in my code, or give me some tests. var h,s,aa,bb:real; a:array[1..3,1..2] of integer; i,l:integer; procedure readdata; begin readln(a[1,1],a[1,2],a[2,1],a[2,2]); readln(a[3,1],a[3,2],l); end; procedure writedata; begin writeln(aa:0:2); writeln(bb:0:2); end; function d(x1,y1,x2,y2:integer):real; begin d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); end; procedure square; var p,a1,a2,a3:real; begin a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]); a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]); a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]); p:=(a1+a2+a3)/2; s:=sqrt(p*(p-a1)*(p-a2)*(p-a2)); end; begin readdata; square; h:=d(a[1,1],a[1,2],a[2,1],a[2,2]); aa:=s/(0.5*h); if d(a[1,1],a[1,2],a[3,1],a[3,2])<aa then aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]); bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]); if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]); if (s/(0.5*h))>bb then bb:=(s/(0.5*h)); aa:=aa-l; bb:=bb-l; writedata; end. SEE 2 1 4 2 0 0 1 YOUR: -1.00???? 3.47 AC: 1.24 3.47 Re: SEE Послано SSS 13 апр 2005 23:23 What do you think how it can be changed? I think to change the decision is necessary. :):):):):):):):):):):):):):):)+++++++++++++++++++++ Re: I think to change the decision is necessary. Послано SSS 15 апр 2005 11:05 I'm not talking about decision, decision is right. I said that how code can be changed to get AC? Here is modified one: I modified my code, it gives correct answer for your test but i still get this ****** WA#4 !!! Here is code var a1,a2,a3,h,s,aa,bb:real; a:array[1..3,1..2] of integer; i,l:integer; procedure readdata; begin reset(input);} readln(a[1,1],a[1,2],a[2,1],a[2,2]); readln(a[3,1],a[3,2],l); end; procedure writedata; begin writeln(aa:0:2); writeln(bb:0:2); end; function d(x1,y1,x2,y2:integer):real; begin d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); end; procedure square; var p:real; begin a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]); a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]); a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]); p:=(a1+a2+a3)/2; s:=sqrt(p*(p-a1)*(p-a2)*(p-a2)); end; begin readdata; square; if (a1*a1+a2*a2<a3*a3) or (a2*a2+a3*a3<a1*a1) or (a1*a1+a3*a3<a2*a2) then begin aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]); if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]); end else begin h:=d(a[1,1],a[1,2],a[2,1],a[2,2]); aa:=s/(0.5*h); end; bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]); if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]); aa:=aa-l; bb:=bb-l; writedata; end. Re: Here is modified one: Послано SSS 15 апр 2005 20:19 Seems correct but gets WA#4 Re: Here is modified one: aa always >=0 bb always >=0 Before an input in procedure write make terms that was not aa <0 and bb <0 Re: Here is modified one: Maybe I'm Error,But,What mistake you think?I can not to found any mistake Re: Here is modified one: At a conclusion check up that aa and bb were not negative, If they will be negative appropriate him 0. Re: Here is modified one: Послано Snetch 20 дек 2007 04:16 Spaces and line feeds can follow each other in any order, so you need only to Read([1,1],a[1,2],a[2,1],a[2,2],a[3,1],a[3,2],l); Try this: -5 0 5 0 0 5 100 Correct answer is 0.00 0.00 |