Click here to Skip to main content
15,914,109 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get the subkey value using c++ Pin
jeron110-Sep-08 6:36
jeron110-Sep-08 6:36 
GeneralRe: how to get the subkey value using c++ Pin
Mark Salsbery10-Sep-08 7:21
Mark Salsbery10-Sep-08 7:21 
GeneralRe: how to get the subkey value using c++ Pin
jeron110-Sep-08 7:27
jeron110-Sep-08 7:27 
GeneralRe: how to get the subkey value using c++ Pin
Perspx10-Sep-08 8:28
Perspx10-Sep-08 8:28 
QuestionProblem in Permutations Pin
ron_jay10-Sep-08 4:44
ron_jay10-Sep-08 4:44 
QuestionRe: Problem in Permutations Pin
CPallini10-Sep-08 5:18
mveCPallini10-Sep-08 5:18 
AnswerRe: Problem in Permutations Pin
ron_jay10-Sep-08 6:05
ron_jay10-Sep-08 6:05 
GeneralRe: Problem in Permutations Pin
CPallini10-Sep-08 11:09
mveCPallini10-Sep-08 11:09 
Well, I had troubles following the logic of your program hence rewrite my own version based on the requirements. It is almost plain C, if you feel its output correct then you can easily incapsulate it in a class.
#include "stdafx.h"
#include <string.h>

void choose(char in[20], int len, int width, int level);
int main(int argc, char* argv[])
{
  char in[] = "abcd"; 
  choose2(in, 4,3,0);
  return 0;
}


void swap(char & a, char & b)
{
  char t = a;
  a = b;
  b = t;
}


void choose(char in[20], int len, int width, int level)
{
  int i;
  char out[20];
  memcpy( out, in, 20);
  if ( level == width)
  {
    for (i=0; i<level; i++)
    {
      putchar(out[i]);
    }
    putchar('\n');
    return;
  }
  choose(out, len, width, level+1);
  for (i=level+1; i<len; i++)
  { 
    swap(out[level],out[i]);
    choose(out, len, width, level+1);
  }
}


BTW the program is far from being optimized.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: Problem in Permutations Pin
ron_jay10-Sep-08 20:19
ron_jay10-Sep-08 20:19 
QuestionHow to identify an EXE is whether a COM component or Not Pin
NiceNaidu10-Sep-08 3:20
NiceNaidu10-Sep-08 3:20 
AnswerRe: How to identify an EXE is whether a COM component or Not Pin
Chris Losinger10-Sep-08 7:00
professionalChris Losinger10-Sep-08 7:00 
GeneralRe: How to identify an EXE is whether a COM component or Not Pin
Michael Dunn10-Sep-08 11:31
sitebuilderMichael Dunn10-Sep-08 11:31 
GeneralRe: How to identify an EXE is whether a COM component or Not Pin
Chris Losinger10-Sep-08 11:51
professionalChris Losinger10-Sep-08 11:51 
GeneralRe: How to identify an EXE is whether a COM component or Not Pin
NiceNaidu10-Sep-08 18:35
NiceNaidu10-Sep-08 18:35 
QuestionDual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 3:02
logiqworks10-Sep-08 3:02 
AnswerRe: Dual monitor, pop up window goes to primary display Pin
SandipG 10-Sep-08 3:29
SandipG 10-Sep-08 3:29 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 4:50
logiqworks10-Sep-08 4:50 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 5:01
logiqworks10-Sep-08 5:01 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
vishalmore10-Sep-08 20:05
vishalmore10-Sep-08 20:05 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 21:58
logiqworks10-Sep-08 21:58 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
SandipG 10-Sep-08 20:21
SandipG 10-Sep-08 20:21 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 21:56
logiqworks10-Sep-08 21:56 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
SandipG 10-Sep-08 22:46
SandipG 10-Sep-08 22:46 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
logiqworks10-Sep-08 23:21
logiqworks10-Sep-08 23:21 
GeneralRe: Dual monitor, pop up window goes to primary display Pin
SandipG 10-Sep-08 23:34
SandipG 10-Sep-08 23:34 

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.