Puas yog 2d arrays sib txuas?
Puas yog 2d arrays sib txuas?

Video: Puas yog 2d arrays sib txuas?

Video: Puas yog 2d arrays sib txuas?
Video: Puas Yog Koj Deev Hluas Nraug 2024, Kaum ib hlis
Anonim

Hauv C, a ob seem array yog suav tias yog ib qhov seem array ntawm kab, uas yog, lawv tus kheej, ib seem arrays . Yog li ntawd, a ob seem array ntawm integers, AA, yog khaws cia ua a sib txuas ib theem zuj zus ntawm cov ntsiab lus, txhua qhov uas yog ib qhov loj me array.

Hais txog qhov no, puas yog arrays sib txuas?

Ib array yog a sib txuas sau los ntawm homogeneous ntsiab uas tuaj yeem nkag tau siv qhov ntsuas. Los ntawm sib txuas , peb txhais cov ntsiab lus ntawm cov array nyob ib sab ntawm ib leeg hauv kev nco tsis muaj qhov sib txawv ntawm lawv. Los ntawm homogeneous, peb txhais tau tias lawv txhua tus ntawm tib hom.

Tsis tas li ntawd, cov arrays thiab cov pointers puas tuaj yeem siv sib hloov ua lus C? Cov taw qhia thiab array npe ua tau zoo heev be siv interchangeably . Muaj kev zam. Koj muab tsis tau ib tug tshiab taw tes nqi rau ib array npe. Cov array npe yuav ib txwm taw tes rau thawj lub ntsiab ntawm lub array.

Tib neeg kuj nug, yuav ua li cas 2d array khaws cia hauv lub cim xeeb?

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.

Puas yog 2d arrays sib txuas hauv C?

Hauv C , a ob seem array yog suav tias yog ib qhov seem array ntawm kab, uas yog, lawv tus kheej, ib seem arrays . Yog li ntawd, a ob seem array ntawm integers, AA, yog khaws cia ua a sib txuas ib theem zuj zus ntawm cov ntsiab lus, txhua qhov uas yog ib qhov loj me array.

Pom zoo: