Hello friends,
there is yet another problem for you...
We have got a string say HOUR
Now we need a program that can choose the specified number of words say n from this word in all possible ways and displays them ...for example in this case
for n=3 the output should be
HOU
OUR
URH
RHO

Recommended Answers

All 2 Replies

>there is yet another problem for you...
I've already solved that problem. Perhaps you meant to say "This is my homework".

>Now we need a program that can choose the specified number of
>words say n from this word in all possible ways and displays them
As much as it sounds like you want us to hand you the solution on a silver platter, I'll offer some advice. Do a google search for generating permutations. C++'s standard library has two functions that allow you to step through the permutations of a sequence, but I imagine your teacher wants you to do it manually.

And what have you done so far? :)

It's rather interesting:
n!/(x!*(n-x)!) different combinations, where n is size of string typed, and x is size of output strings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.