0
java help
I don't know how to write code like this. The method returns those array elements in which the specified value does not occur. For example: I have a method like: static int[] arr(int[] a, int digits) then System.out.println(arr({5,245,4564,90}, 5)) and output is [90] .Such outputs because 90 doesn't have number 5, only 9 and 0 I am new in java and is for my class, I am not necessarily needing a ready-made solution but maybe algorithm or tips for solving this problem by myself. Thank you so much
9 Respuestas
+ 4
Kasia Herasymenko
You mean something like this:
https://code.sololearn.com/c7wayVmAMiL4/?ref=app
num = 5
a = {5,245,4564,90}
outer for loop: loop through the array
* d = a [i]
* l = length of a [i]
* boolean same = false
inner for loop:
* with d% 10 you get the last digit of a number (e.g. 45: 45% 10 = 5)
* check if this digit = given num
--> yes: same = true
* cut the last digit of d --> d/10
Back to the outer for loop:
* if same = false --> no digits of a [i] = given num --> add it to the list
return list
+ 3
Kasia Herasymenko Your welcome :)
+ 1
Do you have the complete code of that project?
+ 1
https://code.sololearn.com/cLZjk21rCqp9/?ref=app
That you want to do?
+ 1
What means that 5 in values?
+ 1
Thank you so much for help:)
0
No, I dont know how to start :(
0
no, I have a method like: static int[] arr(int[] a, int values)
then System.out.println(arr({5,245,4564,90}, 5)) and output is [90] .Such outputs because 90 doesn't have number 5, only 9 and 0
0
digits