2d arrays khaws cia hauv lub cim xeeb li cas?
2d arrays khaws cia hauv lub cim xeeb li cas?

Video: 2d arrays khaws cia hauv lub cim xeeb li cas?

Video: 2d arrays khaws cia hauv lub cim xeeb li cas?
Video: Thov Txim Qhov Kuv Txav Deb Ntawm Koj (Official Music Video 2022) N. Vajxob Xyooj & N. Vanxay lauj 2024, Hlis ntuj nqeg
Anonim

A 2D array yog khaws cia hauv computer nco ib kab tom qab lwm tus. Yog hais tias txhua tus nqi ntawm cov ntaub ntawv array xav tau B bytes ntawm nco , thiab if array muaj cov kab C, ces cov nco qhov chaw ntawm lub ntsiab lus xws li qhab nia [m][n] yog (m * c + n) * B los ntawm qhov chaw nyob ntawm thawj byte.

Hauv qhov no, yuav ua li cas 2d array sawv cev hauv kev nco?

Sawv cev ntawm ob seem array hauv nco yog kab loj thiab kab loj. Nyob rau hauv lub computer nco matrices yog khaws cia nyob rau hauv kab-major order los yog Column-major order form. Kab-major order thiab kem-major order yog txoj kev khaws cia multidimensional arrays nyob rau hauv linear cia xws li random nkag nco.

Tom qab ntawd, lo lus nug yog, yuav ua li cas multidimensional array khaws cia hauv nco hauv Java? Hauv Java , ib array khaws cov khoom tseem ceeb (int, char,) lossis cov ntaub ntawv (a.k.a pointers) rau cov khoom. Thaum ib qho khoom tsim los ntawm kev siv "tshiab", a nco qhov chaw tau faib nyob rau hauv heap thiab ib qho kev siv rov qab.

Kuj paub yog, arrays khaws cia hauv lub cim xeeb li cas?

Ib array khaws nws cov khoom sib txuas nco qhov chaw. Yog koj tsim lub array hauv zos nws yuav nyob rau pawg. Qhov twg cov ntsiab lus yog khaws cia nyob ntawm qhov chaw cia khoom specification. Ib tug dynamically tsim array yuav tsim nyob rau hauv heap.

Dab tsi yog 2d array?

2 Dimensional Arrays . Zoo li 1D array , a 2D array yog ib phau ntawm cov ntaub ntawv hlwb, tag nrho cov tib hom, uas yuav muab tau ib lub npe. Txawm li cas los xij, a 2D array yog koom ua ib tug matrix nrog ib tug xov tooj ntawm kab thiab kab.

Pom zoo: