I have a little problem, I don't quite understand how to make a toothed (a notched?) matrix in C++. The matrix should be like this (with 4 columns and 6 rows):
But I keep getting a matrix in the form of a triangle, i.e. no repeating rows are displayed. How can I fix it? I'm attaching a piece of code, but I don't think it will help much.
(N are rows, M are columns)
for (int i = 0; i < N; i++) {
matrix[i] = new double[M];
for (int p = 0; p <= i; p++) {
matrix[i][p] = rand() % 101 - 50;
cout << setw(5) << matrix[i][p];
}