Click here to Skip to main content
15,902,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: error C2440 Pin
MsmVc5-Apr-10 22:13
MsmVc5-Apr-10 22:13 
AnswerRe: error C2440 Pin
Fareed Rizkalla4-Apr-10 23:12
Fareed Rizkalla4-Apr-10 23:12 
GeneralRe: error C2440 Pin
MsmVc4-Apr-10 23:28
MsmVc4-Apr-10 23:28 
GeneralRe: error C2440 Pin
Fareed Rizkalla5-Apr-10 4:14
Fareed Rizkalla5-Apr-10 4:14 
GeneralRe: error C2440 Pin
MsmVc5-Apr-10 19:13
MsmVc5-Apr-10 19:13 
QuestionHow can generate Max. Combination of given Value? Pin
Le@rner4-Apr-10 19:58
Le@rner4-Apr-10 19:58 
AnswerRe: How can generate Max. Combination of given Value? Pin
Adam Roderick J4-Apr-10 20:02
Adam Roderick J4-Apr-10 20:02 
GeneralRe: How can generate Max. Combination of given Value? Pin
Le@rner4-Apr-10 20:19
Le@rner4-Apr-10 20:19 
int fac(int n)
{
  if (n == 0) return 1;
  else return n*fac(n - 1);    	    
}

void permute(char *string, int n, int rank)
{
  vector<char> vec;
  for (int ctr = 0; ctr < n; ctr++) vec.push_back(string[ctr]);

  for (int ctr = n; ctr >= 1; ctr--)
    {
      int quotient = rank/fac(ctr-1);
      char c = vec[quotient];
      vec.erase(vec.begin()+quotient);
      *string++ = c;
      rank%=fac(ctr-1);    	 
    }    		  
}

void showpermutes(char *string)
{
  char temp[20];  	
  int n = strlen(string);    	
  // if the string is too big, we can't continue
  if (n > 19) return;
  int nfac = fac(n);
  for (int ctr = 0; ctr < nfac; ctr++)
    {	         
      strcpy(temp, string);    	     
      permute(temp, n, ctr);    	     
      cout << temp << endl;
    }     		       
}

int _tmain(int argc, _TCHAR* argv[])
{
	showpermutes("AB");
	system("PAUSE");
	getche();
	return 0;
}

GeneralRe: How can generate Max. Combination of given Value? Pin
Adam Roderick J4-Apr-10 21:01
Adam Roderick J4-Apr-10 21:01 
GeneralRe: How can generate Max. Combination of given Value? Pin
Le@rner4-Apr-10 21:24
Le@rner4-Apr-10 21:24 
GeneralRe: How can generate Max. Combination of given Value? Pin
Adam Roderick J4-Apr-10 21:35
Adam Roderick J4-Apr-10 21:35 
GeneralRe: How can generate Max. Combination of given Value? Pin
Le@rner4-Apr-10 21:39
Le@rner4-Apr-10 21:39 
GeneralRe: How can generate Max. Combination of given Value? Pin
CPallini5-Apr-10 0:11
mveCPallini5-Apr-10 0:11 
Questioncombinations repetition allowed Pin
MsmVc4-Apr-10 19:33
MsmVc4-Apr-10 19:33 
AnswerRe: combinations repetition allowed Pin
CPallini5-Apr-10 0:13
mveCPallini5-Apr-10 0:13 
QuestionCString multiple assignment leak? Pin
TechAvtar4-Apr-10 19:12
TechAvtar4-Apr-10 19:12 
AnswerRe: CString multiple assignment leak? [modified] PinPopular
LunaticFringe4-Apr-10 19:30
LunaticFringe4-Apr-10 19:30 
AnswerRe: CString multiple assignment leak? Pin
Adam Roderick J4-Apr-10 20:15
Adam Roderick J4-Apr-10 20:15 
GeneralRe: CString multiple assignment leak? Pin
TechAvtar4-Apr-10 21:35
TechAvtar4-Apr-10 21:35 
GeneralRe: CString multiple assignment leak? PinPopular
Adam Roderick J4-Apr-10 21:40
Adam Roderick J4-Apr-10 21:40 
AnswerRe: CString multiple assignment leak? Pin
Joe Woodbury5-Apr-10 6:41
professionalJoe Woodbury5-Apr-10 6:41 
QuestionSecond Window in Win32 Pin
Fareed Rizkalla4-Apr-10 14:51
Fareed Rizkalla4-Apr-10 14:51 
AnswerRe: Second Window in Win32 Pin
enhzflep4-Apr-10 15:09
enhzflep4-Apr-10 15:09 
GeneralRe: Second Window in Win32 Pin
Fareed Rizkalla4-Apr-10 20:53
Fareed Rizkalla4-Apr-10 20:53 
GeneralRe: Second Window in Win32 Pin
enhzflep5-Apr-10 1:59
enhzflep5-Apr-10 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.