Home computickets Are there three-dimensional arrays in Pascal, how to use them?

# Are there three-dimensional arrays in Pascal, how to use them?

Author

Date

Category

Is there a three-dimensional Pascal array?
If so, give an example of using, please.

``````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 anything

Here is another visual example, for which multidimensional arrays can be used. In fact, of course, the database is now used for this. Suppose you want to collect statistics on forum participants. At first you have two indicators: Forums and cities. With the help of a two-dimensional array, you can describe what forum from what cities how many users registered.

Next you want to describe users more detailed. For example, by the nature of the activity. So that it was fashionable to know how many participants from the city A who registered on the forum A, is representatives of the Group C:

turned out a three-dimensional array. The simplest thing that comes to mind is then to determine the same thing, only divided into time. That is, separately for 2012, 2011, 2010, etc. It turns out a 4-dimensional array:

‘result 0. I do not understand anything’

So it is clear. When creating new `Integer `their meaningful value is `0 `And when creating `String `their default value is `'' `i.e. an empty line. This is the same elementary rules!

exists. And four-dimensional too. And even five-dimensional, but hardly such arrays are used somewhere in practice. Announced / used completely similar to 2-dimensional.

Unlike endless spatial dimensions, arrays are finite, so nothing interferes with the “next” with each other.

Sample code:

``````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 there are in Turbo Pascal, and in Free Pascal it works great: http://ideone.com/obsal

Example of a multidimensional array “From life”. Suppose the book is a three-dimensional array of letters (3 coordinates – page, line, number of the letter in the row). Now we take a stack of books – this is already a 4-dimensional array of letters (another dimension is a book number in a stack). We put a few stack of books nearby – 5 measurements. We put the stacks into several rows – 6 measurements. We ship the book with stacks in trucks – 6 Measurement appeared – the truck number. Well, so on.

Three-dimensional array on Pascal:

``````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;
``````

result 0. I do not understand anything

zero and will, the assignments for the elements of the array was not, therefore all the elements are 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 to 23, the remaining elements are zero}
Writeln (A [5,5,5]);
end.
``````

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.