### Create N matrices simultaneously.

closed account (GbX4GNh0)
I would like to create N matrices of dimension (n,k) simultaneously. Lets say for example that N=3. Could you please help me. I read the command a[n][k][N] but I don't understand how to use it.

Please help me, I know that for some of you this question is silly but I' m new to this language and I have noone else to ask.
There are no "commands" in C++.

There are statements and expressions (instructions and calculations), and there is data (and data types).

It is simplest if you try not to think of it all at once:

 ``12`` ``````#include // C++ using namespace std;``````
 `` `` ``#include // C ``
 ``12345678910111213141516171819202122232425262728293031323334353637383940`` ``````const int n = 3; const int k = 4; // A matrix data type typedef double matrix_t[n][k]; // A function that works on a matrix void print_matrix( matrix_t M ) { for (int ni = 0; ni < n; ni++) { for (int ki = 0; ki < k; ki++) { // cout << M[ni][ki] << "\t"; // C++ // printf( "%lf\t", M[ni][ki] ); // C } //cout << "\n"; // C++ //puts( "" ); // C } } int main() { // Some matrices to play with matrix_t one_matrix; matrix_t many_matrices[ 10 ]; // Assign values to your matrices here. ... // Now let's display our stuff to the user. print_matrix( one_matrix ); for (int i = 0; i < 10; i++) { print_matrix( many_matrices[i] ); } return 0; }``````

Hope this helps.
Topic archived. No new replies allowed.