#include <iostream>
#include <conio>
int main()
{
int i, j;
int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12};
for(i=0; i<=2; i++)
{
for(j=0; j<=3; j++)
cout<<"a["<<i<<"]["<<j<<"] = "<<a[i][j]<<"\t";
cout<<"\n";
}
getch();
return 0;
}
Hi, can I know how to read code in line 7? I mean "1" is at a[0][0]? "2" is at a[0][1]? why can't "2" at a[1][0]? How is the row and column define in this c++ actually? Thanks...
It's technically just an array of arrays. If you wan to call it row and column, that is up to you. It just depends on how you plan to write and read to it.
In your implementation: yes, i represents your rows and j represents your columns. You could just as easily transpose this to make it opposite by doing this:
Thanks...is that mean, int a[3][4] in line 7 control the for loop? I mean if I use my own code above and how to change int a[3][4] in line 7 to make the output like the one u give(Stewbond)? Can I change to something like int a[4][3]?
And is there any default from C++, I mean left is row and right is column? TQ...