You can create an vector of vectors as given below.
vector< vector<int> > arr2d;
read row, col;
for(int i=0; i<row; i++){
vector<int> temp;
for(int j=0; j<col; j++)
temp.push_back(0);
arr2d.push_back(temp);
}
Now you can use arr2d as simple as an array.
arr2d[i][j] = any_value;
Similarly you can create any dimensional arrays dynamically.
On Tue, May 15, 2012 at 6:18 PM, Registered user
<[email protected]>wrote:
> how to create 2d or 3d array dynamically , giving the size at run time :
> for global array....
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
--
Regards,
A.Mohamed Bilal
QA Engineer
GlobalScholar
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.