Hi,
I am trying to search an array of doubles for a number and report the index location(s) of a number. I.e. -allow for repetition. Search and report all index[i] where the number is contained in the array. For example I have
double[] myInputArray = new double[5];
double[] myInputArray = { 1, 2, 3, 3, 5 }
I know how to search through the array ONCE and return the first occurrence of a number:
public double GetIndexOf(double Number) {
for (int i=0; i<myInputArray.length; i++) {
if (myInputArray[i] == Number){
return(i);
}
}
return(-1);
}
How do I expand this code to report multiple index[i] locations if the number reoccurs in the array like the number 3 does in my example array above?