Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Multi-dimensional-array/C/multi-dimensional-array-2.c
Normal file
27
Task/Multi-dimensional-array/C/multi-dimensional-array-2.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include<stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int hyperCube[5][4][3][2];
|
||||
|
||||
/*An element is set*/
|
||||
|
||||
hyperCube[4][3][2][1] = 1;
|
||||
|
||||
/*IMPORTANT : C ( and hence C++ and Java and everyone of the family ) arrays are zero based.
|
||||
The above element is thus actually the last element of the hypercube.*/
|
||||
|
||||
/*Now we print out that element*/
|
||||
|
||||
printf("\n%d",hyperCube[4][3][2][1]);
|
||||
|
||||
/*But that's not the only way to get at that element*/
|
||||
printf("\n%d",*(*(*(*(hyperCube + 4) + 3) + 2) + 1));
|
||||
|
||||
/*Yes, I know, it's beautiful*/
|
||||
*(*(*(*(hyperCube+3)+2)+1)) = 3;
|
||||
|
||||
printf("\n%d",hyperCube[3][2][1][0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue