|
|
back to boardi thin it's work correct, but can't get acc, please help! Posted by wavejke 21 Jun 2011 16:03 where is my mistake? falls on 5th var i,nr,n,k,c:integer; begin read(n,k); nr:=trunc(n/2); if (k>nr) then begin for i:=nr+1 to k-1 do inc(c); end; if (k<nr) then begin for i:=k+1 to nr do inc(c); end; write(c); end. Re: i thin it's work correct, but can't get acc, please help! Your code is very bad and solution is wrong too. At first nr:=trunc(n/2) n is even because of this you could write nr=n div 2; 2.for i:=nr+1 to k-1 do inc(c); -----> this is very bad code.If you want something like that you should write c:=k-1-(nr+1)+1; 3.end here should be if (k > nr) Writeln(k -3)
else WriteLn(n - k - 2); |
|
|