how can i make this kind of program

when i input a character like "MEEEE" the output will be "EMEEE","EEMEE",EEME" and so on... it just it will rumble the letter until it cannot continue cuz it already have..

when i input a character like "MEEEE" the output will be "EMEEE","EEMEE",EEME" and so on... it just it will rumble the letter until it cannot continue cuz it already have..

heres the problem from my prof

here is another mathematical problem, where the trick is as much to discover the algorithm as it is to write the code; write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have multiple repeated results. input should be of the form permute string and output should be a word per line.

here is a sample for the input cat

cat

cta

act

atc

tac

tca

here is another mathematical problem, where the trick is as much to discover the algorithm as it is to write the code; write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have multiple repeated results. input should be of the form permute string and output should be a word per line.

here is a sample for the input cat

cat

cta

act

atc

tac

tca

Are you allowed to use standard algorithms?

http://www.cplusplus.com/reference/algorithm/next_permutation/

All you have to do is change it from an integer array to a string (and change the iterators in the function calls as well) and it works.

On a side note, the next time you have a question, please choose an appropriate title (example for this thread:**Finding all permutations of a string**), post a clear description of the problem (that includes the problem itself, and any tests cases), post what code you have and let us know where you are having troubles. This not only increases the likelihood of getting a response, but it also makes it much easier for us to answer you in a clear, concise manner.

http://www.cplusplus.com/reference/algorithm/next_permutation/

All you have to do is change it from an integer array to a string (and change the iterators in the function calls as well) and it works.

On a side note, the next time you have a question, please choose an appropriate title (example for this thread:

Topic archived. No new replies allowed.