Traditional Culture Encyclopedia - Traditional culture - For two-dimensional arrays, there are two different storage methods: row first and what.
For two-dimensional arrays, there are two different storage methods: row first and what.
The two-dimensional array a [m] [n] is a two-dimensional array with m rows and n columns. Let a [p] [q] be the first element of a, that is, the row subscripts of a two-dimensional array are from p to m+p, and the column subscripts are from q to n+q. When storing in "row priority order", the address of the element a [i] [j] is calculated as: loc (a [i] [j]) = loc (a [p] p) * n + (j? q)) * t .
When storing by column priority, the address is calculated as: loc (a [I] [j]) = loc (a [p] [q])+((j? q) * m + (i? P)) * T. The number of cells required to store the array is at least (m-p+ 1) * (n-q+ 1) * t bytes.
Extended data:
The elements in the array are stored in order, and they are stored together in memory in this order. All elements in an array are of the same type (they can be of different types, unlike fields in a structural class). Elements in an array are stored in contiguous memory blocks and accessed through indexes (unlike fields in structural classes, they are accessed by name).
When the dimension of the array is increased, the storage space occupied by the array will greatly increase, so we should use multidimensional arrays carefully. Be more careful when using variable arrays because they require more storage space.
- Previous article:What certificate do I need to apply for to open a supermarket?
- Next article:How to review an event
- Related articles
- The coin circle is crazy! Bitcoin broke through $23,000 for the first time. Who's behind this? Can investors still enter the market?
- Which one should 3 yuan store join?
- Vocational school work summary
- How many colors do hydrangeas come in? What is the language of each color?
- Is there a future for cryptocurrency market?
- What's the telephone number of Beijing Innovation DreamWorks Technology Co., Ltd.?
- History of Artificial Intelligence 4 charts of major AI milestones
- What festivals do Tibetans have?
- How to evaluate enterprise value
- Achievements of internationalization or international integration of small and medium-sized enterprises