Показать сообщение отдельно
  #14  
Старый 05.05.2009, 19:17
Аватар для Rokuell
Rokuell Rokuell вне форума
Активный
 
Регистрация: 27.12.2006
Адрес: Псков
Сообщения: 274
Версия Delphi: Delphi 7
Репутация: 497
По умолчанию

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;

Функция вернёт только чётные слова
__________________
Велик и могуч наш Object Pascal !
ICQ: 357-591-887
Ответить с цитированием