Can I print elements of a simple matrix with out manual nested loop?
From: SUPER_SOCKO (am.socko_at_gmail.com)
Date: 02/28/05
- Previous message: Victor Bazarov: "Re: I'm looking for a cheap Compiler"
- Next in thread: Ben Hetland: "Re: Can I print elements of a simple matrix with out manual nested loop?"
- Reply: Ben Hetland: "Re: Can I print elements of a simple matrix with out manual nested loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2005 06:35:40 -0800
Suppose I have a matrix M x N dimension.
Normally, to print all of the elements in the matrix. I write the
following codes:
Suppose M = 5, N = 4:
for(int j=0; j<5; ++j) {
for(int k=0; k<4; ++k) {
cout << matrix[M][N] << " ";
}
cout << endl;
}
If my matrix class has method for return number of dimension and
dimension size such as:
numDimension(matrix); // return 2 becase the matrix has M x N = 2
dimensions.
sizeDimension(0); // return 5 -- size of M
sizeDimension(1); // return 4 -- size of N
How to write some code that print all element of the matrix with out
code nested loops by hand?
Thanks
Nalerk
- Previous message: Victor Bazarov: "Re: I'm looking for a cheap Compiler"
- Next in thread: Ben Hetland: "Re: Can I print elements of a simple matrix with out manual nested loop?"
- Reply: Ben Hetland: "Re: Can I print elements of a simple matrix with out manual nested loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]