- #1
RJLiberator
Gold Member
- 1,095
- 63
Homework Statement
[/B]
1. I've been tasked with forming a 10 x 10 matrix with elements 0, 1, 2, 3, 4, 5,...
and have it display properly.
2. Then, take this matrix and make a 2d-histogram out of it.
Homework Equations
Here is my code
Code:
void matrix6( const int n = 10)
{
float I[n][n]; // Creates a 10*10 matrix
// Homework, put this matrix into a 2-dimensional histogram, it will look cool.for(int i=0; i< n; i++) // This loops on the rows
{
for(int j=0; j< n; j++) // This loops on the columns
{
I[i][j] = i*10+j; cout<< I[i][j] <<" ";
}
cout << endl;
}
return;
}
The Attempt at a Solution
So my code works, in a way. It is nearly perfect except the first line of the matrix is slightly offset. I am not sure how to fix this problem. Any suggestions? I have attached a picture of it to show you what I mean. The first row is offset.
The bigger problem is task #2. What does it even mean to make a 2d histogram out of a 10x10 matrix with elements that just count up from 1? My professor suggested that this would 'look cool.'
I think when I have a more clear picture of what it would even look like, I could begin to write the code... but it's making mathematical sense to me right now.
Attachments
Last edited: