Hey so right now i am having trouble with trying to find duplicate numbers of decimals in a vector
here is an example of what i am looking for
6.578947
The number 7 first occurs in position number 2.
this i basically the kind of output that I want
Any help is appreciated
thanks
You can use two for loops to check for duplicates. One for loop to keep track of the number you're searching for in the loop, the second one to check for duplicates and return the first for loop's position if found.
the standard approach is to sort the data, or a copy of it, and compare adjacent items for dupes.
floating point, you might want to check a tolerance rather than equality, depending on what you think is best. for example is 0.999999999999999 == to 1.000000000000000000001 ?