|
|
вернуться в форум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. 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. thanks very much. I got ac now. It's very kind of you. |
|
|