Link to home
Start Free TrialLog in
Avatar of Chrysaor
Chrysaor

asked on

List all possible combinations of x numbers taken y at a time , in C++

Is there a function or a library which has a function for this problem : I have x numbers (e.g 5) , and I want to list all possible combinations in of these numbers taken y (e.g 3) at a time. For example, let's say we have these 5 numbers: 1, 3, 5, 6, 7 , I want to print all the possible combinations taken 3 at time, which means 135, 356,567 etc etc.

If there is not such function, can you provide me the basic guidelines to build such a function? thanks a lot.
Avatar of albuitra
albuitra
Flag of Colombia image

The position of the number is important ?
So is equal 135, 351, 531, 513 or do you count it like a diferent combination ?
SOLUTION
Avatar of rstaveley
rstaveley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial