Answer the question
In order to leave comments, you need to log in
What is the error in the code, pascal ((12): Run-time error: Index was out of array bounds.)?
program p1;
type
massive = array of integer;
function PolMos(a: massive; n: byte): char;
var
c, i: byte;
begin
c := 0;
for i := low(a) to high(a) div 2 do
if a[i] <> a[high(a) - i + 1] then c := 1;
if c = 0 then writeln(chr(13), 'Массив является палиндромом')
else writeln(chr(13), 'Массив не является палиндромом');
end;
function massiv(n: byte): char;
var
i: byte;
a: massive;
begin
setlength(a, n);
randomize;
for i := low(a) to high(a) do
begin
a[i] := random(n);
write(a[i]:4);
end;
PolMos(a, n);
end;
var
n: byte;
begin
write('Введите размер массива: '); read(n);
write('Массив: '); massiv(n);
end.
Answer the question
In order to leave comments, you need to log in
The index was outside the bounds of the array
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question