Click here to Skip to main content
15,907,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
Yes, sorry about that. Apart from the missing cout << endl; line already mentioned it gives the following output

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

Blush | :O Blush | :O

I can provide a recursive function if you relax the requirement for it to take only one parameter:

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

using namespace std;


int func(int x, int y);


int main(int argc, char *argv[])
{	
  func(1, 4);	
  return 0;
}


int func(int x, int y)
{
  int i;	
  for (i=1; i<=x; i++)	
  {		
    cout<<"* ";	
  }	
  cout << endl;	
  if(x != y)
  {
    func(x + 1, y);
    for (i=1; i<=x; i++)	
    {		
      cout<<"* ";	
    }	
    cout << endl;	
  }
  return 0;
}


Graham

Librarians rule, Ook!

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 
GeneralRe: number and string Pin
sofia_1117-Jun-08 10:58
sofia_1117-Jun-08 10:58 
GeneralRe: number and string Pin
Graham Shanks7-Jun-08 11:11
Graham Shanks7-Jun-08 11:11 
GeneralRe: number and string [modified] Pin
sofia_1117-Jun-08 20:55
sofia_1117-Jun-08 20:55 
QuestionRe: number and string Pin
David Crow7-Jun-08 14:32
David Crow7-Jun-08 14:32 
AnswerRe: number and string Pin
sofia_1117-Jun-08 21:15
sofia_1117-Jun-08 21:15 
GeneralRe: number and string Pin
toxcct8-Jun-08 22:36
toxcct8-Jun-08 22:36 
QuestionProgram to Code Pin
Pathetic7-Jun-08 6:21
Pathetic7-Jun-08 6:21 
AnswerRe: Program to Code Pin
Michael Schubert7-Jun-08 6:43
Michael Schubert7-Jun-08 6:43 
GeneralRe: Program to Code Pin
Pathetic8-Jun-08 4:09
Pathetic8-Jun-08 4:09 
AnswerRe: Program to Code Pin
CPallini7-Jun-08 7:00
mveCPallini7-Jun-08 7:00 

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.