Hello, again everyone.

I was just wondering if it is possible to print an entire matrix, sorry if this is just a simple thing that I've missed, but anyway

Thank you in advance

Printable View

- 07-08-2005NebbuchadnezzarPrinting a Matrix?
Hello, again everyone.

I was just wondering if it is possible to print an entire matrix, sorry if this is just a simple thing that I've missed, but anyway

Thank you in advance - 07-08-2005Rashakil Fol
By the power vested in you by the invention of the for loop, yes.

- 07-08-2005Nebbuchadnezzar
I'm guessing you meant something like:

Code:`for (busy==1)`

{

int matrix[5][5]={{1,2,3,4,5},{1,2,3,4,5}}

cout<<matrix[1][0]<<"\n"<<matrix[0][1];

/*and so on */

}

And why I'm here, is it possible to print the names of every instance of 1 class, and allow the user to call a function from 1 of these classes?

Thank you for your help.

And sorry for my stupidity. - 07-08-2005JoshRCode:
`for (int row = 0; row < 5; row++)`

for (int col = 0; col < 5; col++)

cout << matrix[row][col];

- 07-08-2005Dae
Use a for loop and a variable or two to loop through it and make it easier to read.

Code:`int matrix[2][5]={{1,2,3,4,5},{1,2,3,4,5}};`

int i = 0, j = 0;

for(i = 0; i < 2; ++i) {

for(j = 0; j < 5; ++j) {

cout << matrix[i][j];

}

}

Code:`cout << matrix[0][0];`

cout << matrix[0][1];

cout << matrix[0][2];

cout << matrix[0][3];

cout << matrix[0][4];

cout << matrix[0][5];

cout << matrix[1][0];

cout << matrix[1][1];

cout << matrix[1][2];

cout << matrix[1][3];

cout << matrix[1][4];

cout << matrix[1][5];