C++ 2DArray

2DArray problem, HELP!

Page 1 of 1

2 Replies - 450 Views - Last Post: 12 October 2009 - 11:27 AM Rate Topic: -----

#1 Damirz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-October 09

C++ 2DArray

Posted 12 October 2009 - 10:53 AM

Hello!

I am writing a c++ code for displaying a 3D cube.
I have some small problems with arrays.

I want to initialize just some interval of array.

Example:

int array[10][10]=0;

//now I want to initialize just an interval

array[0][5] TO array[0][8]=1;


___________

I know that in place where the word TO is, has do be
some sign, which will do initialization from one place
of array TO another, but I don't know which.

Maybe this is not correct procedure so fell free to tell
me a better solution.

Thanks for help!

Damir

Is This A Good Question/Topic? 0
  • +

Replies To: C++ 2DArray

#2 Autocrat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 4
  • View blog
  • Posts: 307
  • Joined: 27-September 09

Re: C++ 2DArray

Posted 12 October 2009 - 11:26 AM

Create a for loop:

int i;
for ( i = 5; i <= 8; ++i )
{
	  array[0][i] = 1;
}



Is that what you were asking?
Was This Post Helpful? 0
  • +
  • -

#3 aks29921  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 84
  • View blog
  • Posts: 230
  • Joined: 24-August 09

Re: C++ 2DArray

Posted 12 October 2009 - 11:27 AM

use nested for loops

for (i=1;i<=3;i++)
{
for (j=0;j<=2;j++)
array[i][j]=1;
}


this initialises values from array[1][0] to array[3][2], i.e. array[1][0],array[1][1],array[1][2],array[2][0] and so on..

This post has been edited by aks29921: 12 October 2009 - 11:28 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1