I had a typo in the inner loop, fixed. However,
int n=Math.sqrt(matrix.length)
doesn't compile.
Type: Posts; User: The Witchking
I had a typo in the inner loop, fixed. However,
int n=Math.sqrt(matrix.length)
doesn't compile.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Draft.toArray(Draft.java:215)
at Draft.main(Draft.java:247)
is given. also, can i use math.sqrt(x) on int[]...
ill use a counter inside the loops to track the array index.
for array back to matrix i think this would work
array[i]----goes to---->matrix[i/n][i%2]
n is always even and array size is n^2....
for a matrix nxn ill create a new array n^2 long. how though would i index m[i][j] in a lop into its respective slot array[k]?
Yes, you are right, it would fold that way. However, the function I am trying to get will receive a 2d matrix. I need to apply the changes for it. since i do have a properly working function for a 1d...
I will attach here the following function, proven to work:
The function will get an array representing a binary number. It will increment this number to the next larger binary number with the exact...
I can not find a better solution, that is why I am here for, to consult and draw on your experience.
I will attach the following function code that increments a binary number represented in a 1d...
:) Now was an hour ago. Later is now. I would like to improve it. But hey, I just don't know how.
My thanks for the correspondence tho, I did made me realize at least one possible solution,...
Is there no other way?
The word of a seasoned programmer would be enough for me to settle for the above mentioned solution and stop trying something more efficient.
Thank you.
Q:"Why a 2D array?"
A:The matrix represents a possible board and therefore must be 2d.
Q:"What problems are you having? Do you have the algorithm for generating the binary numbers?"
I have an...
Q:"How would 01101 be stored in a 2D array?"
A: This number is equal to 000001101 and would be presented by a 2d matrix NxN, where n=3, k=3:
000
001
101
Valid Example:
For N=6, K=9,...
Q:"What code do you have so far?"
A:I have a working function that when given a 2d matrix representing a binary number, will increment it to the next larger number with the same number of bits...
Hello everyone,
I am trying to write a function that does the following:
When given int n and int k, it will:
E.G.
Given n=2 and k=1, the function will create a matrix for the following...