I have to implement a code to generate a 2D array. Given N and L that are size of array. I need to generate matrix A such as
for i=1 to N
for j=1 to L
if(random(0,1)>0.5)
A[i][j]=1;
else
A[i][j]=0;
end
end
end
Let call all above code is in intial() function. Let N=10; L=100; How to make the function initial() that return a 2D array A. Thanks
This is my code
const int N=10;
const int L=100;
int A[N][L];
int [][] initialization()
{
for (int i=0;i<10;i++)
for (int j=i;j<100;j++)
{
if(random(0,1)>0.5)
A[i][j]=1;
else
A[i][j]=0;
}
return A;
}