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
C++ 2DArray2DArray problem, HELP!
Page 1 of 1
2 Replies - 323 Views - Last Post: 12 October 2009 - 11:27 AM
Replies To: C++ 2DArray
#2
Re: C++ 2DArray
Posted 12 October 2009 - 11:26 AM
Create a for loop:
Is that what you were asking?
int i;
for ( i = 5; i <= 8; ++i )
{
array[0][i] = 1;
}
Is that what you were asking?
#3
Re: C++ 2DArray
Posted 12 October 2009 - 11:27 AM
use nested for loops
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..
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
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|