Program of Permutations....?

Hello everybody,
I have to make a program in an Object orientd manner, such that
If I enter a string 'FOR'

then the output will be....All possible permutations of 'FOR' as

FOR
FRO
OFR
ORF
RFO
ROF
For the srings having any no. of haracters.........?

if you give me the answer then thank you in advance...!

Comments

  • this might help: [link=http://cplusplus.com/reference/algorithm/next_permutation.html]next_permutation()[/link].
    sample pseudo code:
    [code]
    take the string input in a variable, say inp;
    while (not all permutations are output) {
    output inp;
    call next_permutation(inp.begin(), inp.end());
    }
    [/code]
    note that if inp is a character array containing N letters, excluding the terminating NULL, the following pseudo code works:
    [code]
    take the string input in a variable, say inp;
    while (not all permutations are output) {
    output inp;
    call next_permutation(inp, inp+N);
    }
    [/code]
    [hr][purple]~Donotalo()[/purple]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion