How to print permutations?

S

Shraddha

If we have three variables a,b,c...which are char variables....then
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....
 
D

Deniz Dogan

Shraddha said:
If we have three variables a,b,c...which are char variables....then
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....

Are all of these questions school work or something?
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

If we have three variables a,b,c...which are char variables....then
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....

Perhaps std::next_permutation() can be of use.
 
O

osmium

Shraddha said:
If we have three variables a,b,c...which are char variables....then
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....

Use std::next_permutation() in <algorithm>.
 
S

Shraddha

Are all of these questions school work or something?

Hi Deniz...
This is not a school work...
Actually these permutations are not supposed to be printed mannually.
There is a formula for that permutations....b'coz of which we can do
that program within 5-7 lines...that works not only for 3 variables
but for n number of characters.
But I am not aware of that formula...so I just want to know that
formula....
 
J

John Harrison

Shraddha said:
Hi Deniz...
This is not a school work...
Actually these permutations are not supposed to be printed mannually.
There is a formula for that permutations....b'coz of which we can do
that program within 5-7 lines...that works not only for 3 variables
but for n number of characters.
But I am not aware of that formula...so I just want to know that
formula....

http://www.von-oppen.com/doc/cuj/html/20.03/nelson/nelson.htm

It has the 'formula' you want (actually the algorithm) if you are
prepared to do a little work and actually understand.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top