how do I get the seek function to return 1if it's seeking multiple specific items in this case 2,3,5 | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

how do I get the seek function to return 1if it's seeking multiple specific items in this case 2,3,5

public class program{ public static int Seek(int[]arr,int num) { for(int i:arr){ if(num==i) { return 1; } } return 0; } public static void main (String [] args){ int[] myarray={2,3,5,7,11}; System.out.println (Seek (myarray,(2),(3,(5))); } }

21st Mar 2017, 8:16 AM
Ricardo Chitagu
Ricardo Chitagu - avatar
3 ответов
+ 2
1. The tag specific is not a good tag, instead tag the programming language, return and function.
21st Mar 2017, 2:28 PM
Eldar Bakerman
+ 1
What do you mean?
21st Mar 2017, 3:08 PM
Eldar Bakerman
+ 1
the code should look for multiple specific items and not only one... for example. the code is looking for items 2,3,5.if they are there in the array it shut return 1 else 0.
21st Mar 2017, 3:12 PM
Ricardo Chitagu
Ricardo Chitagu - avatar