Lazarus

Free Pascal => Beginners => Topic started by: pascal111 on May 07, 2021, 04:14:08 pm

Title: Initializing ​multi-dimensional array at the declarition time [SOLVED]
Post by: pascal111 on May 07, 2021, 04:14:08 pm
في السطر التالي من كود أحد البرامج وجدتُّ شحناً للمصفوفة أثناء عمليّة الإعلان عنها ولكنّ هذه المصفوفة ذات بعدٍ واحد ،فماذا لو كانت المصفوفة مُتعددة الأبعاد فكيف يُمكن شحنها بقيم أوليّة عند بدء الإعلان عنها في قسم المتغيرات.

google translate:

"In the next line of the code of one of the programs, I found a shipping "initializing" for the matrix during the process of announcing "declaring" it, but this matrix is ​​one-dimensional, so what if the matrix is ​​multi-dimensional, how can it be charged with initial values ​​when it is announced "declared" in the variables section."

Code: Pascal  [Select][+][-]
  1. INTERVALS: array[0..5] of Integer = (1000, 300, 100, 40, 20, 10);
  2.  
Title: Re: Initializing ​multi-dimensional array at the declarition time
Post by: lucamar on May 07, 2021, 04:40:01 pm
Code: Pascal  [Select][+][-]
  1.   INTERVALS: array[0..5, 0..1] of Integer =
  2.     { It's equivalent to array[0..5] of array[0..1], so:}
  3.     ((1000, 0), (300, 1),
  4.      ( 100, 2),  (40, 3),
  5.      (  20, 4),  (10, 5));
Title: Re: Initializing ​multi-dimensional array at the declarition time [SOLVED]
Post by: pascal111 on May 07, 2021, 04:44:19 pm
Thanks, I got the idea now.
TinyPortal © 2005-2018