WORDCNT - Word Counting

Tác giả: flashmt

Ngôn ngữ: Pascal

var c,lc:char;
    t,i,cur,pre,j:byte;
    let:set of char;
    max,dem:integer;

begin
     let:=[];
     for c:='a' to 'z' do let:=let+[c];
     readln(t);
     for i:=1 to t do
     begin
          cur:=0; max:=1; dem:=0;
          repeat
                read(c);
                while (ord(c)=32) and (ord(lc)=32) do read(c);
                if c in let then inc(cur)
                else
                begin
                     if cur=pre then inc(dem)
                     else
                     begin
                          if dem>max then max:=dem;
                          dem:=1;
                     end;
                     pre:=cur;
                     cur:=0;
                end;
                lc:=c;
          until eoln;
          if cur=pre then inc(dem);
          if dem>max then max:=dem;
          readln;
          writeln(max);
     end;
end.

Download