0
vlado_036's Avatar, Join Date: Aug 2006
Go4Expert Member
I taste some changes in the code but I still can`t get the output as I need.

A is caracter on the first pace, B is on the second, C in on the thirdth....
The caracters should not change their places, I need the combinations of them without changing their places.

Pls help me about it, I need to complete this goal as soon as it possible
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Refer http://www.codeproject.com/cpp/CombC.asp
0
vlado_036's Avatar, Join Date: Aug 2006
Go4Expert Member
OK I found some usfull code.
Here is the function which works exactly what I need but only with numbers smaller then 10.
Code:
void Combination(CString arrayN[], __int64 n_column, CString arrayR[], __int64 r_size, __int64 r_column, __int64 loop)
{
  __int64 localloop = loop;
  __int64 local_n_column = n_column;
  	
  if(r_column>(r_size-1))
  {
       CString strCombination = "";
       for(int e=0; e<r_size; e++)
	strCombination += arrayR[e];
       m_lbLista1.AddString(strCombination);
       return;
  } 
 	 	
  for(__int64 i=0;i<=loop;i++)
  {
      arrayR[r_column]=arrayN[n_column+i];
      local_n_column++;
      Combination(arrayN,local_n_column,arrayR,r_size,r_column+1,localloop);
      localloop--;
  }
}
I enter two numbers "N" and "R"(e.g. N=9, R=7, function shows all the combinations 7 of 9), then I create array "arrayN" with N elements and "arrayR" with R elements.
When the N and R are smaller then 10 it works excelent, but for any other number larger than 10 it does not work corectly.
Can somebody tel me what should be changed in the function to work with numbers larger than 10?

Last edited by shabbir; 28Aug2006 at 22:45.. Reason: Code formatting
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
I would suggest you to use the code block while posting the code in the posts.

Also try creating a seperate threads for different problem as that helps many other people to see.