Create a two-dimensional array or array that contains four (04) columns and the rows that you indicate by keyboard
There they are asking you to use dynamic memory:
int filas;
cout << "Digite el numero de filas: ";
cin >> filas;
int** matriz = new int*[filas];
for( int i=0; i<filas; i++ )
matriz[i] = new int[4];
// Resto del codigo
// ...
// Limpieza de la memoria
for( int i=0; i<filas; i++ )
delete[] matriz[i];
delete[] matriz;
The first three columns will have consecutive numbers starting from 1 and the 4th column will be the result of multiplying the previous three columns.
That is, you do not have to ask the user to enter any additional number ... they are all self-calculated:
for( int fila=0, numero=1; fila<filas; fila++ )
{
int producto = 1;
// Rellenamos las tres primeras columnas
for( int columna=0; columna<3; columna++, numero++ )
{
matriz[fila][columna] = numero;
producto *= numero;
}
// Y ahora la celda del producto
matriz[fila][3] = producto ;
}
And well, although it does not indicate it explicitly in the exercise, it is supposed that the table must be shown:
for( int fila=0; fila<filas; fila++ )
{
for( int columna=0; columna<4; columna++ )
std::cout << matriz[fila][columna] << ' ';
std::cout << '\n';
}
Although you can leave it cooler with the columns correctly aligned ... but it requires a preprocess:
#include <iomanip>
#include <cmath>
int max = std::log10(matriz[filas-1][2])+1;
for( int fila=0; fila<filas; fila++ )
{
for( int columna=0; columna<4; columna++ )
std::cout << std::setw(max) << matriz[fila][columna] << ' ';
std::cout << '\n';
}
log10
allows you to calculate the number of digits of a number. example:
log10(100) = 2
log10(999) = 2.XXXX
log10(1000) = 3
All you have to do is add one to get the correct result ... that will be the width of all the columns. Why do I consult a cell in question? The column with the most digits will be the fourth, but since it is the last one, it does not matter how wide it is ... I am more interested in columns with the incremental values and of them the most interesting cell is the last one, since it will be the one with the the largest number of digits.
And with this you already have the problem solved.