I need some help. here is the assignment description:
Write a program that generates a diamond pattern of stars. The user is prompted for the number of stars for the largest row in the pattern and the program must call a recursive function to generate it.
I can get half of to produce but not in the shape of a diamond. Any pointers on how to make it appear as a diamond would be great.
Here is my code thus far:
CODE
#include <iostream>
#include <string>
using namespace std;
void printStars(int count, int num);
int main() {
cout << "Enter the number for the largest line to print: ";
int x;
cin >> x;
int ind = 1;
printStars(ind, x);
system("PAUSE");
return 0;
}
void printStars(int count, int num)
{
for (int i = 0; i < count; i++) cout << "*";
cout << endl;
if (count < num) printStars(count + 1, num);
for (int i = 0; i < count; i++) cout << "*";
cout << endl;
}
//Output should look similiar depending on the number for the largest row
// *
// * *
// * * *
// * * * *
// * * *
// * *
// *