Uhmm.....ships come in fleets, soldiers come in platoons...I think.
A simple 3 dimensional array could be written as int a [3][3];//3 cols and 3 rows
It could also be written as int a [][]={{3,2,7},{4,2,7},{6,5,9}};
or int a [3][3]={3,2,7};//where only the first 3 elements 0 - 2 are initialized with specific values and the remaining 6 elements 3 - 8 are initialized with default 0
or int a=(3,2,7,4,2,7,6,5,9};// so the simplest form of a multi-dimensional array is the single dimensional array
If you want to display the above use nested for loops:
1 2 3
|
for(int i=0;i<3;i++)//defines row elements
for(Int j=0;j<3;j++) //defines column elements
cout<<a[i][j]<<" ";
| |
prints
3 2 7
4 2 7
6 5 9