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

ft ! I submit it nearly 20 times.But I also get wa? Could anyone help me ? Or give me some input which my prog give the wrong answer?OK?
Posted by liuzhizhi 7 Aug 2004 21:34
This is my program:
var
 total:longint;
procedure init;
 var
  a:char;
  start:boolean;
  w:longint;
 begin
  read(a);
  start:=true;
  w:=0;
  repeat
   if not(a in[' ',';',':','-',',']) then
    begin
     if a in['.','!','?'] then
      begin
       start:=true;
       w:=0;
      end else
     if a in['A'..'Z'] then
       begin
        if w<>0 then inc(total);
        if (w=0)and(start) then start:=false;
        inc(w);
       end else
     if a in['a'..'z'] then
      begin
       if start=true then
        begin
         inc(total);
         start:=false;
        end;
       inc(w);
      end;
    end else w:=0;
  read(a);
  until eof;
  writeln(total);
 end;

begin
 init;
end.
Re: ft ! I submit it nearly 20 times.But I also get wa? Could anyone help me ? Or give me some input which my prog give the wrong answer?OK?
Posted by Sandro 9 Aug 2004 14:03
I found your mistake.
"A word is a sequence of letters not containing any other symbols or ends of line."

But your program doesn't check the ends of lines. Try this test:

This sentence iz correkt! -It Has,No mista;.Kes et
oll. But there are two
BIG mistakes in this one!
and here is one more.

The answer is 3, but your program output 4. You can easily modify your program:

if not(a in[' ',';',':','-',',',#10]) then

and all must be fine.
Re: ft ! I submit it nearly 20 times.But I also get wa? Could anyone help me ? Or give me some input which my prog give the wrong answer?OK?
Posted by zhizhiliu 9 Aug 2004 14:09
thanks very much.
I got ac now.
It's very kind of you.