How to print permutations?

Discussion in 'C++' started by Shraddha, May 25, 2007.

  1. Shraddha

    Shraddha Guest

    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....
     
    Shraddha, May 25, 2007
    #1
    1. Advertising

  2. Shraddha

    Deniz Dogan Guest

    Shraddha wrote:
    > 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?
     
    Deniz Dogan, May 25, 2007
    #2
    1. Advertising

  3. On 25 Maj, 14:44, Shraddha <> wrote:
    > 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.

    --
    Erik Wikström
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, May 25, 2007
    #3
  4. Shraddha

    osmium Guest

    "Shraddha" writes:

    > 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>.
     
    osmium, May 25, 2007
    #4
  5. Shraddha

    Shraddha Guest

    On May 25, 5:50 pm, Deniz Dogan <> wrote:
    > Shraddha wrote:
    > > 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?


    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....
     
    Shraddha, May 26, 2007
    #5
  6. Shraddha wrote:
    > On May 25, 5:50 pm, Deniz Dogan <> wrote:
    >> Shraddha wrote:
    >>> 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?

    >
    > 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
     
    John Harrison, May 26, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. anurag

    print all permutations of string

    anurag, Jul 20, 2006, in forum: C Programming
    Replies:
    20
    Views:
    1,763
    Mark P
    Jul 25, 2006
  2. anurag
    Replies:
    18
    Views:
    9,179
    karteek007
    Apr 17, 2009
  3. Shraddha

    to print permutations...

    Shraddha, May 26, 2007, in forum: C Programming
    Replies:
    5
    Views:
    2,257
    Malcolm McLean
    May 26, 2007
  4. keto
    Replies:
    0
    Views:
    998
  5. sanket
    Replies:
    3
    Views:
    520
Loading...

Share This Page