User Tools

Site Tools


ro:dim

This is an old revision of the document!


Dim (Declarație)

Format

Crearea unei matrici cu o singură dimensiune

Crearea unei matrici cu două dimensiuni

Crearea unei matrici dintr-o listă de elemente

Copierea unei matrici

Umplerea unei matrici cu o singură valoare

dim variabilă fill expresie
dim variabilă[] fill expresie

Descriere

Returns a newly created single dimensional array of length integer or a 2 dimensional array that can be addressed by row and column. By default the elements in the array are left uninitialized (empty), You may add the fill option to fill all elements with a single value.

The first element of an array has an index of 0 (zero). Indexes range from 0 to length-1.

The dim statement can also be used to create a new array that is a duplicate of another array. The form “DIM var = var” does this by dimensioning a new array in memory and copying all of the data from the original array.

Exemplu

dim z = {1, 2, 3, 4, 5}
print z[0] + " " + z[4]

va afișa

1 5

Alt exemplu

dim c(4)
c[0] = "aleargă"
c[1] = "mult"
c[2] = "leneșul"
c[3] = "mai"
print c[2] + " " + c[3] + " ";
print c[1] + " " + c[0] + "!"

va afișa

leneșul mai mult aleargă!

Vezi și

Istoric

1.99.99.55Cleaned up documentation and added array copy.
1.99.99.56Added fill clause
1.99.99.57Added additional fill options
1.99.99.72added the [] when setting one array from another
ro/dim.1502100493.txt.gz · Last modified: 2020/02/28 10:46 (external edit)