Click here to Skip to main content
15,891,012 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ 6 with Excel Sheets Pin
kasi1410-Sep-08 8:47
kasi1410-Sep-08 8:47 
Questionhow to get the subkey value using c++ Pin
adhilingam10-Sep-08 5:20
adhilingam10-Sep-08 5:20 
QuestionRe: how to get the subkey value using c++ Pin
Mark Salsbery10-Sep-08 6:27
Mark Salsbery10-Sep-08 6:27 
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 
I have a serious problem which i am not being able to figure. This program finds all the permutations of a given string using recursion. The diagnostic outputs show that the values of the 'choice' and 'final' character arrays is not maintained at a position (I don't know why). Please help.

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
using namespace std;

class Permutation
{
  private:
    static char s[20];
    int width,l;
  public: 
    void input();
    void compute();
    void recur(char choice[],char final[],int);
};
char Permutation::s[20];

void Permutation::input()                                 
{
  cout<<"Enter the string:";
  gets(s);
  cout<<"Places to arrange:";
  cin>>width;
};

void Permutation::compute()
{
  l=strlen(s);
  char s1[20]; 
  recur(s,s1,0);
}

void Permutation::recur(char choice[],char final[],int p)
{
   int i,j,chk,c=0;
   if(p==width){//base condition
     cout<<"OUT: "<<final;
	 cout<<endl;
	 return;
   }	  
   //setting choice variables
   for(i=0;i<l;i++){>
   	   chk=0;							
       for(j=0;j<strlen(final);j++){>
         
	     	 if(s[i]==final[j])
		       chk=1;
       }
	   if(chk==0){choice[c++]=s[i];}
   }
   choice[c]='\0';
    	  
  //traversing recursion	  
  for(i=0;i<c-1;i++){>
    
	final[p]=choice[i];
	final[p+1]='\0';cout<<"Beforein:\t "<<choice<<" -\t "<<final<<" -\t "<<p+1<<" -\t"<<i+1<<" "<<c<<endl<<endl;
	recur(choice,final,p+1);
	
	cout<<"Returned: \t"<<choice<<" - \t"<<final<<" - \t"<<p+1<<"-\t"<<i+1<<" "<<c<<endl<<endl;
  }	    
}

int main()
{
   Permutation arrange;
   arrange.input();
   arrange.compute();
   getch();
   return 0;
}  

</string.h></stdio.h></conio.h></iostream.h>

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 
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 

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.