Click here to Skip to main content
15,906,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi..

Can any one help me in the following problem,which is
I want to get all possible combination of an array which is like this

char S[]={'a','b','c','d','e'......'z'}


I dont know how to go with this...

Thanks and Regards
Posted
Updated 24-Mar-11 3:03am
v2
Comments
CPallini 24-Mar-11 8:37am    
What do you mean, exactly (you know, recursion is at the door...)?
tanu misra 26-Mar-11 1:17am    
I mean to say that i want all combination array S[] which has lower case alphabets for example a,b,........z,aa,ab,ac..... and so on........

quite a nice thread on stackoverflow about this, have a read

http://stackoverflow.com/questions/361/generate-list-of-all-possible-permutations-of-a-string[^]
 
Share this answer
 
Comments
Tarun.K.S 24-Mar-11 9:16am    
Interesting!
try to use inner loop:


C# version:
<code>
  char[ ] arr = { 'a', 'b', 'c', 'd', ......'z'};

  for (int i = 0; i < arr.Length; ++i)
   for (int j = 0; j < arr.Length; ++j) // inner loop
   Console.WriteLine( arr[i] + " : " + arr[j]);

</code>
 
Share this answer
 
v2
Comments
CPallini 24-Mar-11 8:48am    
Well this works for just two elements...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900