1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
using namespace std;
int main()
{
const int n = 4;
//multidimensional array
int array[n][n] = {{1,2,3,32},{4,5,6,33},{7,8,9,34},{10,11,12,35}};
//output the array
cout << "The array contains: {";
for(int i = 0; i < n; ++i)
for(int k = 0; k < n; ++k)
{
if(k == 0) cout << "{";
cout << array[i][k] << ", ";
if(k == n-1 && i != n-1) cout << "\b\b}, ";
}
cout << "\b\b}}" << endl;
}
| |