1 / 16

Int ia[3][6];

Int ia[3][6];. 第一行. 第二行. 第三行. 第四行. 第五行. 第六行. 第一列. 第二列. 第三列. 1000. 1048. 1004. 1052. 第 一 列. 第 三 列. 1008. 1056. 1012. 1060. 1016. 1064. 1020. 1068. 1024. 1028. 第 二 列. 1032. 1036. 1040. 1044. ia[0][4] spans = 1000+(0*6+4)*4=1016  1016~1019

terris
Download Presentation

Int ia[3][6];

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Int ia[3][6]; 第一行 第二行 第三行 第四行 第五行 第六行 第一列 第二列 第三列

  2. 1000 1048 1004 1052 第 一 列 第 三 列 1008 1056 1012 1060 1016 1064 1020 1068 1024 1028 第 二 列 1032 1036 1040 1044

  3. ia[0][4] spans = 1000+(0*6+4)*4=1016  1016~1019 • Ia[2][4] spans = 1000+(2*6+4)*4=1064  1064~1067

  4. 8進位: 124 ÷8 =15 ……4 15 ÷8 = 1 ……7 1 ÷8 = 0 ……1 0174 • 16進位: 124 ÷16 = 7 ……12 7 ÷16 = 0 ……7  07C

  5. 換算成十進位 • 8進位:0174 3 2 1 0 4*80+7*81+1*82+0*83=4+7*8+1*64 =4+56+64=124 • 16進位:07C 2 1 0 12*160+7*161+0*162=12+7*16=12+112 =124

  6. 指標 VS. 陣列 陣列元素 指標語法 整數陣列 假設的記億體位置 *(pi3) 1000 pi3[0] 1001 1002 1003 *(pi3+1) 1004 pi3[1] 1005 1006 1007 *(pi3+2) 1008 pi3[2] 1009 1010 1011 *(pi3+3) 1012 pi3[3] 1013 1014 1015 *(pi3+4) pi3[4] 1016 1017 1018 1019

  7. #include<iostream> using namespace std; Int main() { int i; int *pi=new int(-5); int *pi2=new int(4); int pi3[5]={-3,-1,2,3,4}; for(int i=0;i<5;i++) cout<<*(pi3+i)<<“\n”; 印出pi3陣列的值

  8. pi pi pi pi pi pi2 pi2 pi2 pi2 pi2 i=4 pi3[3]=4 i=2 pi3[2]=2 i=3 pi3[3]=3 4 5 6 7 6 pi=4 pi=6 pi=5 pi=7 pi=8 pi=6 pi2=5 pi2=7 pi2=6 pi3[2]=7 pi3[2]=6 pi3[2]=5 *Pi=-5 *Pi2=4 Pi3[5]= { -3 ,-1 ,2 ,5 ,3 ,6 ,7 ,4 } i=0 pi3[0]=-3 i=1 pi3[1]=-1 for(int i=0;i<5;i++) if(*(pi3+i)>=0) { pi=pi2; *pi=*pi+2; *pi2=*pi2-1; pi3[i]=*pi2; }

  9. Pi3[5]= { -3 ,-1 ,5 ,6 ,7 } for(int i=0;i<5;i++) cout<<*(pi3+i)<<“\n”; for(int i=1;i<4;i++) pi3[i]=*(pi3+i+1)+3; for(int i=0;i<5;i++) cout<<*(pi3+i)<<“\n”; pi3[5]= { 印出pi3陣列的值 -3 ,-1 ,5 ,6 ,7 } pi3[1]=pi3[2]+3  pi3[1]=5+3=8 pi3[2]=pi3[3]+3  pi3[2]=6+3=9 pi3[3]=pi3[4]+3  pi3[3]=7+3=10 pi3[5]= { 印出pi3陣列的值 -3 ,8 ,9 ,10 ,7 }

  10. 傳值、傳址、傳參考的比較

  11. AAA(i,j) i=1,j=2 2 temp void AAA(int v1,int v2) { int temp=v2; v2=v1+3; v1=temp -3; } 1 2 i j 複製 複製 -2 1 2 3 v1 v2

  12. pAAA(&i,&j) i=1,j=2 2 temp void pAAA(int *v1,int *v2) { int temp=*v2; *v2=*v1+2; *v1=temp -2; } 指標值 i的記億體位置 指標值 j的記億體位置 v1 v2 指向 指向 0 1 2 3 i j

  13. rAAA(i, j) i=0,j=3 3 temp void rAAA(int &v1,int &v2) { int temp=v2; v2=v1+4; v1=temp -4; } v2 v1 0 -1 3 4 j i

More Related