Reputation: 91
I have a 1D array that got i*50 elements..i is a random number and 50 is fixed..The 1D array looks like "float array[i*50]"
I wanna convert the 1D array into a 2D array like ,"float array[,50]"..how to do it ?
Upvotes: 1
Views: 324
Reputation: 4294
Does like this ?
int k = 3;
float [] a = new float [k*n];
float [,] b = new float [k, n];
for (int i = 0; i < a.length; i++)
b[i / n, i % n] = a[i];
Upvotes: 3
Reputation: 121789
Upvotes: 0