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.
Any C programmers out there??????
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.
Reply:you need nested loops, something like:
for (int i=0; i%26lt;stringLength; i++)
for (int j=0;j%26lt;stringLength; j++)
{
// rememeber to exclude where i=j
// print out
}
Reply: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 %26gt;2) return;if(rear%26gt;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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment