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 1089. Verification with the Dictionary

Who my program always got wrong?Must the last empty line be output?
Posted by hydra 17 Oct 2001 13:31
const maxn=100;
      maxl=8;
type words=string[maxl];
var vocabulary:array [1..maxn] of words;
    mispell,i,n,l,k,s:byte;
    bf:char;
    now:words;
    mistake:word;
procedure judge;
begin
  if l>0 then
     begin
      now[0]:=char(l);s:=0;
      for i:=1 to n do
       if l=byte(vocabulary[i,0]) then
        begin
         mispell:=0;
         for k:=1 to l do
          if now[k]<>vocabulary[i,k] then
           begin
            inc(mispell);
            if mispell>1 then break;
           end;
         if mispell=0 then begin s:=0;break;end
          else if mispell=1 then s:=i;
        end;
      if s=0 then write(now)
       else
        begin
         write(vocabulary[s]);
         inc(mistake);
        end;
       l:=0;
     end;{if}
end;
begin
 n:=1;
 readln(vocabulary[n]);
 while (vocabulary[n]<>'#') do
  begin
   inc(n);
   readln(vocabulary[n]);
  end;
 dec(n);l:=0;mistake:=0;
 while not eof(input) do
  begin
   read(bf);
   case bf of
    'a'..'z':
    begin
     inc(l);
     now[l]:=bf;
    end
   else
    begin
     judge;
     write(bf);
    end;{else}
   end;{case}
  end;{while}
 judge;
 writeln(mistake);
end.