Recent

Author Topic: Initializing ​multi-dimensional array at the declarition time [SOLVED]  (Read 611 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
في السطر التالي من كود أحد البرامج وجدتُّ شحناً للمصفوفة أثناء عمليّة الإعلان عنها ولكنّ هذه المصفوفة ذات بعدٍ واحد ،فماذا لو كانت المصفوفة مُتعددة الأبعاد فكيف يُمكن شحنها بقيم أوليّة عند بدء الإعلان عنها في قسم المتغيرات.

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.  
« Last Edit: May 07, 2021, 04:43:59 pm by pascal111 »

lucamar

  • Hero Member
  • *****
  • Posts: 4022
Re: Initializing ​multi-dimensional array at the declarition time
« Reply #1 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));
« Last Edit: May 07, 2021, 04:43:35 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Thanks, I got the idea now.

 

TinyPortal © 2005-2018