Cod sursa(job #543276)

Utilizator vendettaSalajan Razvan vendetta Data 27 februarie 2011 20:13:09
Problema Text Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.47 kb
const f = 'text.in'; g = 'text.out';
var
   buf:array[1..1 shl 15] of char;
   ncuv,nlit:longint;
   st:string;
   c:char;
begin
    assign(input,f);reset(input);
    assign(output,g);rewrite(output);
    settextbuf(input,buf);
    while not eof do
        begin
        read(c );
        st := '';
        while ((c >= 'a') and (c <= 'z'))or ((c>='A') and (c<='Z')) do
            begin
            st := st + c;
            inc( nlit );
            read( c );
            end;
        if st <> '' then inc( ncuv );
        end;
    writeln(nlit div ncuv );
    {ncuv:=0;
    while not seekeof(f) do
        begin
            readln(f,s);
            //if s='' then continue;
            //while s[1]=' ' do delete(s,1,1);
            //while s[length(s)]=' ' do delete(s,length(s),1);
            for i:=1 to length(s) do
                if (s[i]<'a') and (s[i]>'z') or (s[i]>'A') and (s[i]<'Z') then
                    delete(s,i,1);
            i:=pos(' ',s);
            while i<>0 do
                begin
                    inc(ncuv);
                    cuv[ncuv]:=copy(s,1,i-1);
                    sol:=sol+length(cuv[ncuv]);
                    delete(s,1,i);
                    i:=pos(' ',s)
                end;
            inc(ncuv);
            cuv[ncuv]:=s;
            sol:=sol+length(cuv[ncuv]);
        end;
    i:=1;
    repeat
        write(g,cuv[i],' ');
        inc(i);
    until i=ncuv;

    write(g,ncuv,' ',sol);
    }
end.