How to appropriate value to the massif

How to appropriate value to the massif

Used at the solution of problems of programming, the structure of data of one type is called the massif. All data of the massif are stored in memory. Access to each element of the massif is provided with the formalized record various for each programming language. For one-dimensional and multidimensional massifs the appeal to its element also differ. It is possible to appropriate value to the massif, having got access to each cell by the name of the massif and having carried out a razymenovaniye of this element of the massif. Filling of the massif with data in language C ++ is possible by means of several forms of records.

Instruction

1. Before filling of the massif define its type of data. In the one-dimensional massif the elements represent the linear sequence, access to which is provided by the consecutive appeal to memory cells. The address of each cell is one unit more senior than previous and begins with zero value.

2. Fill data array of Massiv_I of the numerical int type, dimensional equal 6. Write down a line of a look Massiv_I[0] = 350. Thus, you placed number 350 in the first element of the massif. For the appeal to the second element of the massif the record will look so Massiv_I[1] = 450. To fill all 6 cells, write down the following code: for (int i=0; i <6; i ++) Massiv_I[i] = 250. In each element of the massif there will be number 250.

3. Line information has to is brought in a frame of the quotes established by rules of syntax of language C. So for giving to the first element of the char array * Massiv_S [2] of line value, write down expression of a look: Massiv_S [0] = ""First element"".

4. When filling multidimensional massifs the record becomes complicated, now the razymenovaniye of each cell will be longer. Entering of number 23 in the first cell of the two-dimensional int Massiv_Dv [3][2] array will look so: Massiv_ Dv [0][0] = 23. For filling of all elements of the massif with the same number write down a line of a look: for (int i=0, j=0; i <3, j <2; i ++, j ++) Massiv_ Dv[i][j] = 23. The numerical two-dimensional massif is filled.

Author: «MirrorInfo» Dream Team


Print