S
S
Sobil2020-10-22 02:08:22
Pascal
Sobil, 2020-10-22 02:08:22

Can't convert type array 1.10 of integer to array of integer?

Cannot convert type array 1.10 of integer to array of integer
How to fix?
I work in 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.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2020-10-22
@alexalexes

search_last_index(const massive:array of integer):integer;

array of integer is not the same as array[1..const_mas] of integer.
In function arguments, you must also specify the dimension.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question