ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

teach newfag, plz
Posted by Fedor Faustov 5 Nov 2011 20:17
uses
  SysUtils;

procedure RSqrt(k: Integer);
var
  n: real;
  output: real;
begin
    k:=k+1;
    Read(n);
    if n = -1 then exit;
    output:=Sqrt(n);
    if k > 0 then RSqrt(k-1);
    Writeln(output:0:4);
end;

begin
  while not SeekEof do
    RSqrt(0);
end.
//------------------------------------------

Well, can anybody tell me why it doesn't work? Perhaps, because of this

                         if n = -1 then exit;

Please, don't tell me smth like "go on reading FAQ" or "use your 'while not seekeof do'." Can you just explain my mistake in this code? You know, technically, my program is working right!
Re: teach newfag, plz
Posted by Fedor Faustov 5 Nov 2011 20:20
And yes, I got "crashed (stack overflow)"

Edited by author 05.11.2011 20:20