martes, 6 de mayo de 2014

Multidimensional Arreys

Multidimensional Arreys aren't so easy to understand, the book define it like an array inside another array. Two dimensional arrey is like a table, rows times columns. I will show you a very basic code to help understand a two dimensional arrey.


#include<iostream>
using namespace std;

int main(){

int arrey[2][3]= {{1,2,3},{4,5,6}};

//the first braces[2] are the number of rows
//the second one[3] is the number of columns
for(int row=0; row< 2; row++){//This for loop is to print out the 2 rows (1 2 3)
                                                                                                      //(4 5 6)
for(int column=0; column < 3; column++){ //An this to print out the columns |1| ,|2|,|3|
                                                                                                          //  |4|, |5|,|6|

cout << arrey[row][column] << " "; //prints out the array
}
cout<<endl;
}
system("pause");
return 0;
}



Is not a great code but it's something to have an idea of how a multidimensional arrey works

No hay comentarios.:

Publicar un comentario