Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWord game Pin
Yustme11-Jul-07 22:48
Yustme11-Jul-07 22:48 
AnswerRe: Word game Pin
Rage12-Jul-07 0:17
professionalRage12-Jul-07 0:17 
GeneralRe: Word game Pin
Yustme12-Jul-07 0:34
Yustme12-Jul-07 0:34 
GeneralRe: Word game Pin
Rage12-Jul-07 1:16
professionalRage12-Jul-07 1:16 
GeneralRe: Word game Pin
Yustme12-Jul-07 1:24
Yustme12-Jul-07 1:24 
AnswerRe: Word game Pin
Hans Dietrich12-Jul-07 1:15
mentorHans Dietrich12-Jul-07 1:15 
GeneralRe: Word game Pin
Yustme12-Jul-07 1:28
Yustme12-Jul-07 1:28 
AnswerRe: Word game Pin
Yustme12-Jul-07 1:23
Yustme12-Jul-07 1:23 
Hi,

I found an algorithm which was used for an int array.

I modified it so i can use it for my char array.

It works good but not as how i wanted it to work.

This is how it looks like right now:

<br />
void permute(char *v, const int start, const int n);<br />
void print(const char *v, const int size);<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
	char v[] = {'a', 'v', 'e', 'd', 'k', 'u', 'r', 'n', 'e'};<br />
  permute(v, 0, sizeof(v)/sizeof(char));<br />
	<br />
	system("pause");<br />
	return 0;<br />
}<br />
<br />
void print(const char *v, const int size)<br />
{<br />
  if (v != 0) <br />
	{<br />
    for (int i = 0; i < size; i++) <br />
    {<br />
			cout << v[i];<br />
    }<br />
		cout << endl;<br />
  }<br />
} // print<br />
<br />
<br />
void permute(char *v, const int start, const int n)<br />
{  <br />
  if (start == n-1)<br />
    print(v, n);<br />
  <br />
	else <br />
	{<br />
    for (int i = start; i < n; i++) <br />
		{<br />
      char tmp = v[i];<br />
      <br />
      v[i] = v[start];<br />
      v[start] = tmp;<br />
      permute(v, start+1, n);<br />
      v[start] = v[i];<br />
      v[i] = tmp;<br />
    }<br />
  }<br />
}<br />


It's making letter combinations with only all letters.

It should actually start with 2 letters and then continue until all 9 letter combinations are found.
AnswerRe: Word game Pin
cp987612-Jul-07 2:13
cp987612-Jul-07 2:13 
QuestionHow to get the Instance Handle from a Process ID&#65311; Pin
Billypon11-Jul-07 22:26
Billypon11-Jul-07 22:26 
AnswerRe: How to get the Instance Handle from a Process ID&amp;amp;#65311; [modified] Pin
Nibu babu thomas11-Jul-07 22:29
Nibu babu thomas11-Jul-07 22:29 
QuestionResources for STL Pin
vipin_nvk11-Jul-07 22:12
vipin_nvk11-Jul-07 22:12 
AnswerRe: Resources for STL Pin
SandipG 11-Jul-07 22:37
SandipG 11-Jul-07 22:37 
AnswerRe: Resources for STL Pin
jhwurmbach11-Jul-07 22:42
jhwurmbach11-Jul-07 22:42 
AnswerRe: Resources for STL Pin
Rage12-Jul-07 0:20
professionalRage12-Jul-07 0:20 
QuestionDrag and Drop of a Bitmap Pin
baerten11-Jul-07 21:48
baerten11-Jul-07 21:48 
QuestionExceptions Pin
tom groezer11-Jul-07 21:30
tom groezer11-Jul-07 21:30 
AnswerRe: Exceptions Pin
SandipG 11-Jul-07 21:39
SandipG 11-Jul-07 21:39 
AnswerRe: Exceptions Pin
jhwurmbach11-Jul-07 22:46
jhwurmbach11-Jul-07 22:46 
AnswerRe: Exceptions Pin
DevMentor.org12-Jul-07 11:04
DevMentor.org12-Jul-07 11:04 
GeneralRe: Exceptions Pin
tom groezer13-Jul-07 0:19
tom groezer13-Jul-07 0:19 
GeneralRe: Exceptions Pin
DevMentor.org13-Jul-07 12:12
DevMentor.org13-Jul-07 12:12 
QuestionListbox Pin
harsha u11-Jul-07 21:17
harsha u11-Jul-07 21:17 
AnswerRe: Listbox Pin
jhwurmbach11-Jul-07 22:54
jhwurmbach11-Jul-07 22:54 
GeneralRe: Listbox Pin
harsha u11-Jul-07 23:11
harsha u11-Jul-07 23:11 

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.