![]() |
Newbie prob:how to make combinations without repeatition
About the code in making the numbers from 1-42, in different combinations without repeatition, by 6 numbers, is there any function about that?, hmmmm... i cant find the answer on this... i know im going to use the for loop but i cant find the solution... pls help me hnx
example: collection of numbers from 1-7 answer: 123456 123457 123467 123567 124567 134567 234567 Thanks for helping a newbie prob |
Use nested for loops, where the start or end conditions of inner loops are determined by the value controlling outer loops.
|
uh, what the hell are you trying to do? "making numbers"? w/o repitition there is the fundamental theorem of arithmetic, which might help you.
|
Next time, post in the proper forum: "Software design and algorithms".
:
std::vector<std::vector<value> > |
By the way, that will use ten metric fucktons of memory if you run it with a lot of values. If you needed to find all the combinations of a large set of values, but you didn't need to hold them all in memory at once, it'd be far better to implement as find_first_combination() and find_next_combination() functions.
|
| All times are GMT -5. The time now is 10:07 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC