A
A
Alexander2017-12-01 17:06:27
Pascal
Alexander, 2017-12-01 17:06:27

How in Pascal to create an array of the length that the user entered?

In general, what I need in Python looks like this:

n = int(input("Введите число: "))
a = [i for i in range(n)]
How to do this in Pascal? On the Internet, I was advised to simply declare the array in this way: But something tells me that this is a bad form.
Var a: array[1..999999] of integer;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Leonov, 2017-12-01
@AlexNineteen

Use dynamic array

var
  a: array of integer;
 
begin
  setlength(a, 10);
 end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question