+ 1
How to get an index of Array even if this index is greater than the Array length ?
I have in my code an Array of char that represents all the 10 numbers ( 1,2,3,4,5,6,7,8,9,0), and I want to get the number at index 24 for example. If I search the 13th slot, I want to get 3 in output. I'm looking for a function or formula witch works if I input 345 for example Thanks :)
7 Antworten
+ 5
wait .... what..... but there is nothing in those spots? its sorta like pulling a rabbit out of a hat but you forgot to put the rabbit up your sleave...
+ 4
ummm ok. wierd. but ok
+ 1
My code is a password encryption, that's why i need to loop into
+ 1
hi,
modify your array to begin with 0 and return value modulo 10
i put an example in ruby but it is easy to read
arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
val = 24
puts arr[val%10]
val = 20
puts arr[val%10]
val = 345
puts arr[val%10]
0
The thing :
I want to loop into the Array a x number of times to get a spot
0
Oh un breton :D
Merci !
0
zut démasqué 😔