///////
//
// Student: RussellLowke
//     T.F: Francis Crick
// Unit Two, pencil-and-paper - question 6 [worth 2pts],  7/1/2002
//
//  Write a C++ program to produce a pyramid

#include <iostream>

// constants
const int    ROWS      = 10,  // Number of ROWS (width)
             COLUMNS   = 19;  // Number of COLUMNS (height)
const char   SYMBOL    = '*'; // symbol used to draw pyramid
const double HALFWIDTH = COLUMNS / 2.0;  // Half of triangle width (Middle)
    
void main()
{
    //
    // draw triangle
    //
    
    double tEdge;   // for edge of triangle
    
    // loop through height (rows)
    for (int y = 0; y < ROWS; y++) {
    
        // Start a new line
        cout << endl << "  ";
        
        // find edge of triangle
        tEdge = y * (HALFWIDTH / ROWS);
          
        // loop through width (columns)
        for (int x = 0; x < COLUMNS; x++) {
            if ( (x > HALFWIDTH - tEdge - 1)  &&
                 (x < HALFWIDTH + tEdge) )
                cout << SYMBOL;  // solid
            else
                cout << " ";  // empty
        }
    }
       
    // finish the image
    cout << endl << endl;
}