Cod sursa(job #560599)

Utilizator ForkeySandoiu Fernando Forkey Data 18 martie 2011 16:35:56
Problema Text Scor 30
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.68 kb
program text2;
var s:string;
    c:char;
    p,i,z,n:integer;
    f,g:text;
begin
    assign(f,'text.in');
    reset(f);
    assign(g,'text.out');
    rewrite(g);
    read(f,s);
    p:=0;
    n:=length(s);
    i:=1;
    z:=0;
    s[0]:=' ';
    repeat
       c:=s[i];
       if ((c=' ') or (c='-') or (c=',') or (c='.') or (c='!') or (c='?')) and ((s[i-1]<>' ') and (s[i-1]<>'-') and (s[i-1]<>',') and (s[i-1]<>'.') and (s[i-1]<>'!') and (s[i-1]<>'?')) then
            z:=z+1;
       if (c<>' ') and (c<>'-') and (c<>',') and (c<>'.') and (c<>'!') and (c<>'?') then p:=p+1;
       i:=i+1;
    until i>n;
    write(g,p div z);
    writeln(g);
    close(f);close(g);
end.