test array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <stdio.h> int main(void) { int arrayNumber[3][4][5] = { 0, }; // arrayNumber[height][vertical][horizon] int row = 0, column = 0, depth = 0; unsigned int horizon = 0, vertical = 0, height = 0; depth = sizeof (arrayNumber) / sizeof (arrayNumber[0]); // height 240(60) / 80(20) = 3 column = sizeof (arrayNumber[0]) / sizeof (arrayNumber[0][0]); // vertical 80(20) / 20(5) = 4 row = sizeof (arrayNumber[0][0]) / sizeof (int); // horizon 20byte / 4byte = 5 for (height = 0; height < depth; height++) { for (vertical = 0; vertical < column; vertical++) { for (horizon = 0; horizon < row; horizon++) { arrayNumber[height][vertical][horizon] = horizon + vertical + height; printf("%d ", arrayNumber[height][vertical][horizon]); } printf("\n"); } printf("\n"); } printf("height : %d\n", depth); printf("vertical : %d\n", column); printf("horizon : %d\n", row); printf("%p\n", arrayNumber); printf("%p\n", arrayNumber[0]); printf("%p\n\n", arrayNumber[0][0]); printf("%d\n", sizeof (arrayNumber)); printf("%d\n", sizeof (arrayNumber[0])); printf("%d\n", sizeof (arrayNumber[0][0])); return 0; } | cs |
0 개의 댓글:
댓글 쓰기