Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array searching

Status
Not open for further replies.

rewclaus

Programmer
Mar 7, 2005
16
US
Me again. Now that I've figured out a way to add 3 numbers from one set to an array (say arr[60]), 20 numbers from another set to the array, and 36 numbers from yet a third set to the array (and solved my infinite loop problem), I have encountered (what I think may be the last) another problem. I would like to search the array to see if there are any triplicates of numbers from any of the sets. If there are triplicates of any number I would like to delete one of the numbers and add a new random number.

Please if anyone could help me on this it would be greatly appreciated. Again if this questoion is unclear, let me know and I will try to sauce it up a bit.

-rewclaus
 
Well you could sort the array, which would make finding duplicates easier (they would be adjacent to one another).

Or you could produce a histogram of values, and delete the first instance(s) of whatever numbers appear more times than you want.



--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top