+ 3
How to find the length or size of an Unknown Multi-dimensional array??
5 Réponses
0
I know a better way to find the size of M-D Array!!
Here, I wanted to know whether there's any instance variable like <length>!
+ 3
Here is an implementation of my idea in python. Read the comments to learn more if you like
https://code.sololearn.com/c6z7QTNn1MYp/?ref=app
+ 2
I ll give you a hint. Create a function which accepts an array. Store a variable called i equal to 0. Then iterates through each element - either it is a normal value or an array.
Then check the type of the element and if it is an array then call the function recursively. In this recursive method if the element is a not an array it should increment the value of 1 by 1.
And.finally you will have the value of the array
+ 1
Use sizeof() operator in C. Pass array name as argument...
+ 1
Saurabh Gupta
If you want to know if there exists any instance variable like length, then you ask for it.
"How to find the length..." can mean everything and "search for it" would be also an correct answer. ;)
I only know Java:
yourArray.length;