program split1;
var
InputStr, AWord: string;
i, j, SpaceCount, LastPos, LastIndex: integer;
a: array of string;
DelItems: array of integer;
begin
InputStr := '1 2 3 4 5 6 7 8 9 0';
WriteLn(InputStr);
//Что-то для удаления
SetLength(DelItems, 3);
DelItems[0] := 2;
DelItems[1] := 5;
DelItems[2] := 7;
//Очистим лишние пробелы по краям
InputStr := Trim(InputStr);
for i := 1 to Length(InputStr) do
if InputStr[i] = ' ' then Inc(SpaceCount);
//Размер массива
SetLength(a, SpaceCount + 1);
//Очистка
LastPos := 1;
LastIndex := 0;
AWord := '';
//По циклу
for i := 1 to Length(InputStr) do
begin
if InputStr[i] <> ' ' then
AWord := AWord + InputStr[i];
if (InputStr[i] = ' ') or ((i + 1) > Length(InputStr)) then
begin
if AWord <> '' then
begin
a[LastIndex] := AWord;
Inc(LastIndex);
LastPos := i;
AWord := '';
end;
end;
end;
//Удаляем
for i := 0 to Length(a) - 1 do
for j := 0 to Length(DelItems) - 1 do
if i = DelItems[j] then
a[i] := '';
//Выводим
for i := 0 to Length(a) - 1 do
if a[i] <> '' then
write(a[i], ' ');
end.