How can I count the total no of unique elements in an array?

Printable View

  • 03-19-2013
    laserlight
    Quote:

    Originally Posted by gevni
    My problem is that array is not sorted, it work fine if i do first sorting.

    That is a good idea, so do it.

    By the way, post your code in [code][/code] bbcode tags instead of list tags.
  • 03-19-2013
    jimblumberg
    So if the array is not sorted then either sort the array, or maybe create an array of numbers found to store the "unique" numbers. Also why are you using "i < size -1" in you for loop, that will probably miss the last element.

    Jim