22.27
Код:
function DeleteOdds(ins:string):string;
var i,n,p1,p2,cnt:integer;
isspace:boolean;
begin
ins := ins + ' ';
n := Length(ins);
cnt := 0;
Result := '';
p1 := 1;
isspace := true;
for i:=1 to n do
begin
if ins[i]=' ' then
begin
if not isspace then
begin
isspace := true;
p2:=i;
cnt := cnt + 1;
if cnt mod 2 = 0 then
begin
if cnt > 2 then Result := Result + ' ';
Result := Result + Copy(ins,p1,p2-p1);
end;
end;
end
else
begin
if isspace then
begin
p1 := i;
isspace := false;
end;
end;
end;
end;
Функция вернёт только чётные слова