2017-10-16 51 views
-1

這可能嗎?我需要做一個二維數組,每個元素應該有一個大小爲2的int數組。在C中的int數組的二維數組?

所以,如果我做一個10x10數組,我需要每個索引有一個[x,y],其中x和y是ints 。

+2

的可能的複製[?如何存儲在c 3D陣列(https://stackoverflow.com/questions/5920944/how-are-3d-arrays-stored -in-c) – zerkms

+2

'int array [10] [10] [2];'或'struct pair {int x,y; } array [10] [10];' – BLUEPIXY

+0

請問在請求之前:https://www.tutorialspoint.com/cprogramming/c_multi_dimensional_arrays.htm – user2887596

回答

2
int array[10][10][2]; 

這裏有一個3D數組。二維數組:數組[..] [..]裏面有2個元素。

或者你可以使用結構。

struct number { 
    int x; 
    int y; 
}; 

然後:

struct number array[10][10]; 
+0

1.'s/Struct/struct /' 2.'s /數組數組/結構數組數組/' – zerkms

+0

是的,謝謝!我想問問它只是一個3D陣列...對於我煩惱的人問這個問題很抱歉! – Nico