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

Crash (access violation) PASCAL
Posted by ypjie 24 Aug 2009 11:35
var
  i, n : longint;
  s : string;
  ans : array[1 .. 500000] of real;

procedure work(s : string);
var
  flag, temp : longint;
  num : qword;
begin
  while s <> '' do
  begin
    while s[1] = ' ' do delete(s, 1, 1);
    flag := pos(' ', s);
    if flag = 0 then flag := length(s) + 1;
    val(copy(s, 1, flag - 1), num, temp);
    delete(s, 1, flag);
    n := n + 1;
    ans[n] := sqrt(num);
  end;
end;

begin
  while not eof do
  begin
    readln(s);
    work(s);
  end;
  for i :=n downto 1 do writeln(ans[i] : 0 : 4);
end.
Re: Crash (access violation) PASCAL
Posted by DMKaplony 8 Oct 2009 16:46
I'm sorry, but i dont think yor algorithm is correct..
And .. I crash as well .
I dont know why..

Edited by author 08.10.2009 16:49