Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two dimensional arrays

Status
Not open for further replies.

RichieMac

Programmer
Aug 18, 2004
61
GB
Hi all,

I have a two dimensional array that has to be made one dimensional. How would I go about adding each array on to the end of another. ie:

anArray [3][255] into anArray [3*255].
 
Code:
int [][] x = new int[3][255];
int [] result = new int[3*255];
for(int i=0,3 > i; ++i)
{
  for(int j = 0; 255 > j; += j)
  {  //two ways
     result[i + 3 * j] = x[i][j]; //row major ordering
     //OR
     //result[j + 255 * i] = x[i][j]; //cullom major ordering
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top