Hi..
please help me with this problem
I want to output stars in this shape:
*
* *
* * *
* * * *
* * *
* *
*
just give me the idea to do this in an recursive function ??
i tried but its not showing me the right output..
this is my code:
#include<iostream>
using namespace std;
//function proto Type
void generateStars( int numofLns )
{
if( numofLns==0 )
return;
else
for( int i=1; i<=numofLns; i++ )
for( int j=i; j<=0; j--)
{
generateStars(i-1);
cout<<" * ";
}
cout<<endl;
}
int main()
{
int numOflines;//number of lines in the pattern
cout<<"\nPlease enter the number of lines of the stars:\n";
cin>>numOflines;
//Calling the recursive function to generates the stars
generateStars(numOflines);
return 0;
}//end of main
please help..