Click here to Skip to main content
15,908,013 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: problem in dialog display Pin
Hamid_RT7-Jun-08 21:07
Hamid_RT7-Jun-08 21:07 
GeneralRe: problem in dialog display Pin
Mohanraj D7-Jun-08 21:30
Mohanraj D7-Jun-08 21:30 
GeneralRe: problem in dialog display Pin
Hamid_RT8-Jun-08 2:03
Hamid_RT8-Jun-08 2:03 
AnswerRe: problem in dialog display Pin
sudhir_Kumar7-Jun-08 23:55
sudhir_Kumar7-Jun-08 23:55 
QuestionMFC dialog Question Pin
codedecode7-Jun-08 14:58
codedecode7-Jun-08 14:58 
AnswerRe: MFC dialog Question Pin
Hamid_RT7-Jun-08 19:55
Hamid_RT7-Jun-08 19:55 
AnswerRe: MFC dialog Question Pin
sudhir_Kumar8-Jun-08 0:05
sudhir_Kumar8-Jun-08 0:05 
QuestionRecursive Question Pin
codedecode7-Jun-08 11:16
codedecode7-Jun-08 11:16 
I'm tring to write a recursive function that takes as a parameter a non-negative integer and generates the following pattern of stars if the integer is 4.

*
* *
* * *
* * * *
* * *
* *
*




#include <iostream>
#include <iomanip>
#include<fstream>

using namespace std;


int func(int x);


int main(int argc, char *argv[])
{
	
	
	func(4);
	


	system("PAUSE");
	return 0;
	
}

int func(int x)

{
	int i;


	if (x>=0)
		func(x-1);
			
	for (i=1; i<=x; i++)
	{
			cout<<"* ";
	}
	cout << endl;

	return 1;
	
	

}



Above code gives me

*
* *
* * *
* * * *





Below code gives me

* * * *
* * *
* *
*



#include <iostream>
#include <iomanip>
#include<fstream>

using namespace std;


int func(int x);


int main(int argc, char *argv[])
{
	
	
	func(0);
	


	system("PAUSE");
	return 0;
	
}

int func(int x)

{
	int i;


	if (x<=3)
		func(x+1);
			
	for (i=1; i<=x; i++)
	{
			cout<<"* ";
	}
	cout << endl;

	return 1;
	
	

}




How do I put these codes together to get

*
* *
* * *
* * * *
* * *
* *
*

AnswerRe: Recursive Question Pin
Ravi Bhavnani7-Jun-08 11:24
professionalRavi Bhavnani7-Jun-08 11:24 
GeneralRe: Recursive Question Pin
Nelek7-Jun-08 11:55
protectorNelek7-Jun-08 11:55 
GeneralRe: Recursive Question Pin
Ravi Bhavnani7-Jun-08 17:47
professionalRavi Bhavnani7-Jun-08 17:47 
GeneralRe: Recursive Question Pin
codedecode7-Jun-08 11:56
codedecode7-Jun-08 11:56 
GeneralRe: Recursive Question Pin
Ravi Bhavnani7-Jun-08 17:50
professionalRavi Bhavnani7-Jun-08 17:50 
AnswerRe: Recursive Question Pin
Graham Shanks7-Jun-08 11:28
Graham Shanks7-Jun-08 11:28 
GeneralRe: Recursive Question Pin
codedecode7-Jun-08 11:55
codedecode7-Jun-08 11:55 
GeneralRe: Recursive Question Pin
Nelek7-Jun-08 12:08
protectorNelek7-Jun-08 12:08 
GeneralRe: Recursive Question Pin
codedecode7-Jun-08 13:10
codedecode7-Jun-08 13:10 
GeneralRe: Recursive Question Pin
Graham Shanks7-Jun-08 12:48
Graham Shanks7-Jun-08 12:48 
GeneralRe: Recursive Question Pin
codedecode7-Jun-08 13:28
codedecode7-Jun-08 13:28 
GeneralRe: Recursive Question Pin
Nelek7-Jun-08 13:44
protectorNelek7-Jun-08 13:44 
GeneralRe: Recursive Question Pin
codedecode7-Jun-08 14:33
codedecode7-Jun-08 14:33 
GeneralRe: Recursive Question Pin
Graham Shanks8-Jun-08 23:59
Graham Shanks8-Jun-08 23:59 
AnswerRe: Recursive Question Pin
BadKarma9-Jun-08 3:22
BadKarma9-Jun-08 3:22 
Questionnumber and string Pin
sofia_1117-Jun-08 10:21
sofia_1117-Jun-08 10:21 
AnswerRe: number and string Pin
Graham Shanks7-Jun-08 10:50
Graham Shanks7-Jun-08 10:50 

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.