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 1038. Spell Checker

WHY!? Crash (ACCESS_VIOLATION)
Posted by Akshin 2 Apr 2005 20:40
First of all I got WA at test 4# then I understood that whis error was beacuse I red data by wrong way:
I used " while not eoln " then I changed this to "while not eof" and this test passed on my comp. When submited my program IGot Crash on  test 3#!
Plz help me!
Here is my program:

var
  s:array[1..40] of string;
  n,i,j,k:integer;
  b:boolean;

procedure readdata;
begin
  n:=0;
  while not eof do
  begin
    inc(n);
    readln(s[n]);
  end;
end;


begin
  readdata;
  b:=true;

  for i:=1 to n do
  for j:=1 to length(s[i]) do
  if (b) and ((s[i][j] in ['A'..'Z']) or

(s[i][j] in ['a'..'z'])) then
  begin
    b:=false;
    if s[i][j] in ['a'..'z'] then inc(k);
  end else
  if (s[i][j]='.') or (s[i][j]='!') or

(s[i][j]='?') then
  begin
    b:=true;
  end else
  if (s[i][j] in ['A'..'Z']) then
  begin
    if (j>1) and ((s[i][j-1] in ['A'..'Z'])

or (s[i][j-1] in ['a'..'z'])) then
    inc(k);
  end;
  writeln(k);
end.
Re: WHY!? Crash (ACCESS_VIOLATION)
Posted by wwwwww 2 Apr 2005 21:06
I don't know why, but if you write

's:array[1..100] of string;'

You will have AC.
Re: WHY!? Crash (ACCESS_VIOLATION)
Posted by Alexandrov Sergey 2 Apr 2005 21:32
And I know why:
If a test contains more than 40 lines... your solution will fail, isn't it?