How to remove array element by index in Turbo Pascal?

Given the text up to 255 characters. Words are separated from each other by spaces. To remove from the text the words with these rooms.

My implementation code:
akb program;


procedure DeleteElem<T>(a: array of T; k: word); 
begin 
for var i := k - 1 to length(a) - 2 do 
a[i] := a[i + 1]; 


SetLength(a, length(a) - 1); 

for var i := 0 to length(a) - 1 do 
write(a[i] + ' '); 

end; 

var
text:string;
k:integer;

begin 

 write ('Enter text: ');
phony(text);

 var arr := text.Split(' '); // String is split into words on whitespace
 //writeln(arr[0], ' ', arr[3]); // Слово11 Слово22
 write ('Enter element to delete: ');
phony(k);


writeln('Array after processing: '); 
DeleteElem(arr, k); 
end.

But it does not work on TP.
April 4th 20 at 13:18
1 answer
April 4th 20 at 13:20
Solution

Find more questions by tags Pascal