Here's a simple program using recursion to generate your pattern:
Code:
#include <iostream>
using namespace std;
void DisplayLine(int nCurrentDepth, int nDepth)
{
int i;
for(i = 0; i < nCurrentDepth; i++)
cout << "*";
cout << endl;
if(nCurrentDepth >= nDepth)
return ;
DisplayLine(nCurrentDepth+1, nDepth);
for(i = 0; i < nCurrentDepth; i++)
cout << "*";
cout << endl;
return ;
}
int main(void)
{
int nDepth=0;
cout << "Please enter a number: ";
cin >> nDepth;
cout << endl << "Your pattern looks like this: " << endl << endl;
DisplayLine(0, nDepth);
return 0;
}