[try Beta version]
Not logged in

 
How can I avoid duplicate sets with elegance

Jul 10, 2009 at 10:40pm
Ok. I have a program that basically counts (I'm basically writing this for fun over the summer for the heck of it). It keeps track of a set consisting of 5 separate ints. It avoids outputting sets with duplicates of the same numbers but what I need is an elegant way to avoid sets with the same numbers in a different order. Here's an example of what I'm talking about in the format my program outputs it in:

02 05 18 27 33

18 27 02 33 05


Now, I know I could have it open up the file I'm writing to or write a check program that literally takes a given set and checks each int against every other int in every set written and get if 5/5 numbers match, delete that set but that's kinda ridiculous. I know there's someone with a mind that'll come up with a very simple solution to this. I appreciate any help and thank you for your time.
Jul 10, 2009 at 11:01pm
http://www.cplusplus.com/reference/stl/set/

It will also automatically sort your set.
Last edited on Jul 10, 2009 at 11:02pm
Topic archived. No new replies allowed.