欢迎来到天天文库
浏览记录
ID:14863373
大小:19.43 KB
页数:14页
时间:2018-07-30
《二维数组笔记(two dimensional array notes )》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、二维数组笔记03(Twodimensionalarraynotes03)Twodimensionalarray:Isaone-dimensionalarrayinwhicheachelementisaone-dimensionalarrayThedefinitionformatoftwodimensionalarray:Thattypeofarrayname[rowcolumnindex];Inta[2][3];1)lookattheentiretwo-dimensionalarray:A[i]<=>*(a+i)A[0]*(a+0)Inta[N][M];&a[i][j]C
2、onsidertheaddressofeachelementfromthepointofviewofthearraynameofatwo-dimensionalarray:1)&a[i][j]2)a[0]+i*M+j3)&a[0][0]+i*M+j4)a[i]+j5)*(a+i)+j6)&*(a+i)[j]1)theangleofthefirstaddress:A)thefirstaddressaoftheentiretwo-dimensionalarrayB)thefirstaddressofatwo-dimensionalarrayisalsothefirstaddr
3、essa[0]ofthefirstelementC)canbetheaddress&a[0][0]ofthefirstelementinthefirstelement2)considertheaddressofanyelementonthepreviousbasisA)taketheheadoftheentiretwo-dimensionalarrayasthereferencepoint2)a[0]+i*M+j3)&a[0][0]+i*M+jB)takethefirstaddressofeachelementofadimensionarrayasareferencepo
4、int4)a[i]+j5)*(a+i)+jC)taketheaddressdirectlytoeachspecificelement1)&a[i][j]6)&*(a+i)[j]Waysofreferencingelements:1)*(&a[i][j])<=>a[i][j]2)*(a[0]+i*M+j)3)*(&a[0][0]+i*M+j)4)*(a[i]+j)5)*(*(a+i)+j)6)*(a+i)[j]2)analyzetheaddressoftwodimensionalarrayfromthepointofviewofpointerarray:Pointerarr
5、ay:anarraycontainingmultipleelements,eachofwhichisapointertypeArraypointer:pointer,justapointer,thepointerpointstothespecifiedarrayInta[3][3],*p1,*p2,*p3;P1=a;//errorcannotbeatwo-dimensionalarraynameassignedtoanordinarypointerThetwocontentbasetypesareinconsistentP1=a[0];//legalP2=a[1];P3=
6、a[2];Int*p[3];*[]andallbelongtotheoperator,computingtheprioritylevelisatthesamelevel,combinedwiththerightcombinationDefininganarrayofpointers:Typedescription*arrayname[constantexpression]Adefinitionofmultiplepointerelements,eachelementbelongstotheordinarypointerInta[N][M],*p[N];Inta[3][3]
7、,*p[3];P[0]=a[0];P[1]=a[1];P[2]=a[2];For(i=0;i<3;i++)P[i]=a[i];Leteachpointerofthepointerarraypointtoeachrowofthetwo-dimensionalarray,respectively1)usethepointerarraytorepresenttheaddressofthetwo-dimensionalarrayelement:Theoreticalbasis:Pointertoonedimensionalarray,
此文档下载收益归作者所有