View Feed
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12920 Members
Join this group to post and comment.

Combinations of characters

Can someone give me a code that works as follows:

Input :
A word containing at max 10 "team"

The program should print the different words that can be formed using these letters.
eg:team,tema,taem,tame,tmae,tmea, and so on. So the 4 letters give 4! that is 24 words.

I am stuck up badly as I cant get any idea.Please someone help.😕
Prasad Ajinkya
Prasad Ajinkya • Nov 21, 2008
Here's a hint - Use recursion or while loop.

You need to -
1. first divide the string into an array of characters ... so "team" becomes 't','e','a','m'
2. Then just make a recursive function to output the letter

Get it?
Thanks your advice worked.I got some weird looking code but it worked in some cases.Can you please check it out.
char str[10];
static int index[10];
int len;
int count=0;
void anagram()
  int p,q,flag;
 cout<<"\nThe anagrams found are as follows : \n";
 cout<<"Press enter to get next anagram : \n";

Share this content on your social channels -