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

Ok... another wrong answer... can someone test my program along with his/hers and tell me what's wrong... thnx inadvance
Posted by Costel::icerapper@k.ro 28 Feb 2002 03:44
program timus_p1038;
var
  c:char;
  n:word;
  mistakes:word;
  newphrase:boolean;
  insideword:boolean;

function up(c:char):boolean;
begin
  up:=(c in ['A'..'Z']);
end;

function sign(c:char):boolean;
begin
  sign:=(pos(c,'.,;:-!?'#13#10)<>0);
end;

function letter(c:char):boolean;
begin
  letter:=(upcase(c) in ['A'..'Z','0'..'9']);
end;

function space(c:char):boolean;
begin
  space:=(c=' ');
end;

function digit(c:char):boolean;
begin
  digit:=(c in ['0'..'9']);
end;

begin
  mistakes:=0;
  newphrase:=true;
  insideword:=false;
  while not eof do
  begin
    if eoln then
    begin
      readln;
      insideword:=false;
    end;
    read(c);
    if space(c) then
      insideword:=false;
    while not(eof)and(space(c))do
      read(c);
    if eof then
      break;
    if (newphrase)and(not up(c))and(letter(c))and(not(digit(c))) then
       inc(mistakes);
    if up(c) and insideword then
      inc(mistakes);
    if sign(c) then
    begin
      newphrase:=true;
      insideword:=false;
    end;
    if letter(c) then
    begin
      insideword:=true;
      newphrase:=false;
    end;
  end;
  writeln(mistakes);
end.