Is there a three-dimensional Pascal array? If yes, please give an example of use.
program maasss; var a: array[1..10,1..10,1..10] of byte; begin writeln(a[5,5,5]); end.
Result 0. I do not understand
Is there a three-dimensional Pascal array? If yes, please give an example of use.
program maasss; var a: array[1..10,1..10,1..10] of byte; begin writeln(a[5,5,5]); end.
Result 0. I do not understand
Here is another illustrative example for which you can use multidimensional arrays. Actually, of course, for this purpose now use a DB. Suppose you want to collect statistics on forum members. First you have two indicators: forums and cities. With the help of a two-dimensional array, you can describe what forum from which cities how many users have registered.
Further you want to describe users more detailed. For example, by occupation. So that it would be fashionable to find out how many participants from city A, registered on forum A, are representatives of group C:
The result was a three-dimensional array. The simplest thing that comes to mind next is to determine the same thing, only dividing by time. That is, separately for 2012, 2011, 2010, etc. The 4-dimensional array will turn out:
'Result 0. I do not understand anything'
this is also clear. When creating new integers, their default value is 0
and when creating a string
their default value is ''
that is, an empty string. The same basic rules!
Exists. And four-dimensional too. And even five-dimensional, but hardly such arrays are used somewhere in practice. Declared / used quite similar to the 2-dimensional.
UPD. Here is an illustration of 4 and 5-dimensional arrays:
Unlike infinite spatial dimensions, arrays are finite, so nothing prevents to arrange "side by side" with each other.
UPD2. Code example:
program maasss; var a: array[1..10,1..10,1..10,1..10,1..10] of byte; begin a[1,2,3,4,5]:=123; write(a[1,2,3,4,5]); end.
I do not know how it is in Turbo Pascal, but it works fine in Free Pascal: http://ideone.com/Obsal
UPD3. An example of a multi-dimensional array of "life." Suppose the book is a three-dimensional array of letters (3 coordinates - page, line, letter number in a line). Now we take a pile of books - this is already a 4-dimensional array of letters (another dimension is the number of the book in the stack). We put a few piles of books next to it - 5 dimensions. Put the stack in several rows - 6 dimensions. We load books in piles into trucks - the 6th dimension appeared - the number of the truck. Well, and so on.
Pascal 3D array:
procedure Fnord; const N = 42; type T = array [0..N-1] of array [0..N-1] of array [0..N-1] of Integer; var A: T; begin { ... } A[5,8,2] := 86; { ... } end;
Is there a three-dimensional Pascal array? If so, please give an example. program maasss; var a: array [1..10,1..10.1..10] of byte; begin writeln (a [5,5,5]); end. Result 0. I do not understand
it will be zero, there were no assignments for the elements of the array, so all elements are equal to zero. If you want to see at least some result, do so. program maasss; var a: array [1..10,1..10.1..10] of byte; begin a [5,5,5]: = 23; {this element is assigned the value 23, the remaining elements are equal to zero} writeln (a [5,5,5]); end.
Source: https://ru.stackoverflow.com/questions/107798/