Академический Документы
Профессиональный Документы
Культура Документы
0 1 2 3
10 11 12 13
20 21 22 23
Chapter 7, Slide 1
int main()
{
int x[3][4]={0,1,2,3,10,11,12,13,20,21,22,23};
int i, j;
for(i = 0; i < 3; i++) {
for(j = 0; j < 4; j++)
printf("%2d ",x[i][j]);
putchar('\n');
}
putchar('\n');
for(j = 0; j < 4; j++) {
for(i = 0; i < 3; i++)
printf("%2d ",x[i][j]);
putchar('\n');
}
return 0;
}
Chapter 7, Slide 2
0 1 2 3
10 11 12 13
20 21 22 23
0 10 20
1 11 21
2 12 22
3 13 23
2nd row
0 1 2 3 10 11 12 13 20 21 22 23
const
int* x 1st row 3rd row
Chapter 7, Slide 4
int x[3][4][2] int x[.][4][2]
Chapter 7, Slide 5
int x[3][4][2] int x[3][.][2]
second
index
Chapter 7, Slide 6
int x[3][4][2] int x[3][4][.]
Chapter 7, Slide 7
x[i1][i2]...[in]=*(x + i1*L2*..*Ln + i2*L3*..*Ln +
..+ in-2*Ln-1*Ln + in-1*Ln + in)
0 1 2 3
int** p
4 5 6 7
8 9 10 11
Chapter 7, Slide 8
int** p;
p = malloc(3*sizeof(int*));
if (p == NULL) error();
for(i = 0; i < 3; i++)
p[i]= malloc(4*sizeof(int));
Chapter 7, Slide 9
End of slides for chapter 7
Chapter 7, Slide 10