WORDCNT - Word Counting

Tác giả: ladpro98

Ngôn ngữ: Pascal

program wordcnt;
uses    math;
const   fi='';
var     t,d,temp,res,i,j,k:longint;
        s:ansistring;
        inp:text;
function   getlength:longint;
var     kq:longint;
begin
        kq:=0;
        while s[j]<>' ' do
        begin
                inc(kq);
                inc(j);
        end;
        exit(kq);

end;

begin
        assign(inp,fi);
        reset(inp);
        readln(inp,t);
        for i:=1 to t do
        begin
                res:=0;
                readln(inp,s);
                s:=s+' ';
                temp:=1;
                j:=1;
                t:=getLength;
                d:=t;
                while j<length(s) do
                begin
                while (j<length(s)) and (s[j]=' ') do inc(j);
                t:=getLength;
                if t=d then inc(temp)
                else
                begin
                        temp:=1;
                        d:=t;
                end;
                res:=max(res,temp);
                end;
                res:=max(res,temp);
                writeln(res);
        end;

end.

Download