finding specified NUMBERS in an array
for (i = 0 ; i < list.length ; i++){
if (list[i] == list2[0])
location = i;
break;
ok i have that code which locates a single number but i cant figure out how to continue in the sequence,
i have an array of 50 which is loaded with random numbers between 1-9..
then i input 4 numbers which i place in an array of 4...
then once the random numbers get displayed the user chooses a sequence of numbers say
12345678909214326873196782.........
then the user inputs 9,2,1,4 as the sequence so my question;
how can i get get past the other 9 in the array, all i have is
do{
for (i = 0 ; i < list.length ; i++){
if (list[i] == list2[0])
location = i;
break;
}
if (list[location + 1] == list2[1])
break;
}
while (choice == false);
System.out.println(location);
}
}
Re: finding specified NUMBERS in an array
A sequence as in a bunch of single ints, or more like a String?
That number is a String if just one number.
put code in [highlight=java] Code [/highlight] .