Hello i have to do this:
Write a function that takes 3 arguments, a length, width and height, dynamically allocates a 3-dimensional array with those values and fills the 3-dimensional array with multiplication tables. Make sure to free the array when you are done.
#include <iostream>
usingnamespace std;
void multi (int ***, int, int, int);
int main ()
{
int ***board, x_axis, y_axis, z_axis;
cout << "Enter the number of x axis: " << endl;
cin >> x_axis;
cout << "Enter the number of y axis: " << endl;
cin >> y_axis;
cout << "Enter the number of z axis: " << endl;
cin >> z_axis;
cout << endl;
board = newint** [x_axis];
for (int x = 0; x < x_axis; x++)
board [x_axis] = newint* [y_axis];
for (int y= 0; y < y_axis; y++)
board [x_axis][y_axis] = newint [z_axis];
multi (board, x_axis, y_axis, z_axis);
cin.get();
return 0;
}
void multi (int ***p, int x_a, int y_a, int z_a)
{
for (int x = 0; x < x_a; ++x)
{
for (int y = 0; y < y_a; ++y)
{
for (int z = 0; z < z_a; ++z)
{
p [x] [y] [z] = x * y * z;
}
}
}
cout << "multi table : " << endl;
for (int a = 0; a < x_a; ++a)
{
for (int b = 0; b < y_a;++b)
{
for (int c = 0; c < z_a; ++c)
{
cout << "[" << a << "] [" << b << "] [" << c << "] = ";
cout << p [a] [b] [c] << " ";
cout << "\n";
}
}
}
}
dont rly know where to put the
delete [] board;
and whet its gets to calling the function multi i get