Cod sursa(job #281109)

Utilizator vladcfVlad Frasineanu vladcf Data 13 martie 2009 19:50:20
Problema Text Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.28 kb
var a1,a2:array[1..40] of char;
    s,p:char;
    x,i,l,c:integer;
    f,g:text;
    ok,okc:boolean;
begin
assign (f,'text.in');
assign (g,'text.out');
reset (f);
rewrite (g);
x:=0;
for p:='a' to 'z' do
    begin
    x:=x+1;
    a1[x]:=p;
    end;
x:=0;
for p:='A' to 'Z' do
    begin
    x:=x+1;
    a2[x]:=p;
    end;
l:=0;
c:=0;
okc:=false;
while not(eof(f)) do
      begin
       read (f,s);
       ok:=false;
       for i:=1 to x do
           if a1[i]=s then
              begin
              ok:=true;
              break;
              end;
       if ok=false then
          begin
               for i:=1 to x do
                   if a2[i]=s then
                      begin
                       ok:=true;
                       break;
                      end;
                if ok=true then
                   begin
                    l:=l+1;
                    okc:=true;
                   end
                   else
                   if okc=true then
                   begin
                   c:=c+1;
                   okc:=false;
                   end;
          end
          else
          begin
          l:=l+1;
          okc:=true;
          end;
      end;
writeln (g,abs(l div c));
close (f);
close (g);
end.