English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

friends, please help me with this qn..
write a prog. to print all the combinations of the characters in a string.
(if we enter abc, o/p should be bca ,cab,cba,acb......)

i don't get it.
plz help me.
i need it this week plz plz help.

2006-10-10 05:53:14 · 3 answers · asked by calipsort 2 in Computers & Internet Programming & Design

3 answers

Use nested loops. How would you sort these out in your head? That's basically how the program will do it. The outermost loop is just going to go through each character once. The next loop within that will go through all the characters except for the one that the outermost loop did. The number of nested loops will equal the number of characters in the string.

2006-10-10 06:01:53 · answer #1 · answered by martin h 6 · 0 0

U can use a circular queue to do it best.
I mean for this particular word make an array of 3 cherecters

take 2 indicators, one pointing element and other pointing element after 2 position.
Now lop it such that difference between these two indicator is always 2. and put an extra condition , if(front >2) return;if(rear>2)rear=0;
here front indicates leftmost charecter and rear points last charecter
after each loop increase each front and rear by 1
// here front is first indicator and rear is other indicator

hope it will help
if u need more help . plz mail me(sush_smvdu@yahoo.co.in)
i will mail u compleate source code

2006-10-10 06:32:59 · answer #2 · answered by neo 2 · 0 0

you need nested loops, something like:

for (int i=0; i for (int j=0;j {
// rememeber to exclude where i=j

// print out

}

2006-10-10 06:11:09 · answer #3 · answered by Stanley 3 · 1 0

fedest.com, questions and answers