题目: |
program ex5;
var s:string;
k,I,len,g:integer;
a:array[1..300]of integer;
begin
readln(s);
len:=length(s); a[len] :=0;
For I:=1 to len-1 do
begin k:=i+1;
while(k<=len)and(s[k]<>s[i]) do inc(k);
a[i]:=k-i-1;
end;
for I:=1 to len do
if a[i]>0 then write(a[I]:3);
writeln;
end.
输入:CDCABBADBB 输出: 1 5 7 2 2 3 2
|