
Patrick B. answered 02/28/20
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <conio.h>
#define STAR_ASTERISK_CHAR ('*')
#define AT_SIGN_CHAR ('@')
#define POUND_SIGN_CHAR ('#')
#define DOLLAR_SIGN_CHAR ('$')
#define BLANK_CHAR (' ')
void rowChar ( int n, char ch, bool newLine)
{
for (int iLoop=0; iLoop<n; iLoop++)
{
cout << ch;
}
if (newLine)
{
cout << endl;
}
}
void pause()
{
cout << "Press a key...." << endl;
while (!getch()) { }
}
void PrintRow(char ch, int N, int x)
{
int j = N-x;
rowChar(j,BLANK_CHAR,false);
rowChar(x,ch,true);
}
int main()
{
int n;
cout << "How many to start ??? :>";
cin >> n;
for (int iLoop=n; iLoop>0; iLoop--)
{
PrintRow(STAR_ASTERISK_CHAR,n,iLoop);
}
for (int iLoop=2; iLoop<=n; iLoop++)
{
PrintRow(STAR_ASTERISK_CHAR,n,iLoop);
}
pause();
}