@Sobil

Нельзя преобразовать тип array 1.10 of integer к array of integer?

Нельзя преобразовать тип array 1.10 of integer к array of integer
Как исправить?
Работаю в PacalABC.NET

const
const_mas = 10;
//
//Поиск индекса первого четного числа
//
function search_first_index(const massive:array of integer):integer;
  var i, first_index: integer;
  begin
    for i:= 0 to const_mas do;
      begin
        if massive[i] mod 2 = 0 then
          begin
            first_index:= i
          end
        else 
          begin
            first_index:=0
          end;
      end;
      search_first_index:=first_index
  end;
//
//Поиск индекса последнего четного числа
//
function search_last_index(const massive:array of integer):integer;
  var i, last_index: integer;
  begin
    for i:= const_mas downto 1 do;
      begin
        if massive[i] mod 2 = 0 then
          begin
            last_index:= i
          end
        else 
          begin
            last_index:=0
          end;
      end;
      search_last_index:=last_index
  end;
  
var i, first_index, last_index: integer;
 massive: array[1..const_mas] of integer;
 new_massive: array[1..const_mas] of integer;
    begin
      writeln('введите числа');
      for i:= 1 to const_mas do
        begin
          read(massive[i]);
        end;
        first_index:=search_first_index(massive);
        last_index:=search_last_index(massive);
          if (first_index = last_index) or (first_index = 0) then
            writeln('Пустое множество')
        else 
          for i:=first_index to last_index do
          begin
            new_massive[i]:=i;
            write(new_massive)
          end;
        end.
  • Вопрос задан
  • 589 просмотров
Пригласить эксперта
Ответы на вопрос 1
@alexalexes
search_last_index(const massive:array of integer):integer;

array of integer не тоже самое, что array[1..const_mas] of integer.
В аргументах функций вы тоже должны указать размерность.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы