#include using namespace std; // prints a triangle of stars const int MIDDLE = 40; // where middle of screen is void PrintSpaces(int spaceCount) // post: prints spaceCount spaces on current line { int k; for(k=0; k < spaceCount; k++) { cout << " "; } } void PrintStars(int starCount) // post: prints starCount stars '*' with one space // after each star, all stars on current line { int k; for(k=0; k < starCount; k++) { cout << "* "; } } void PrintTriangle(int rowCount) // post: prints pyramid of stars with rowCount rows { int k; for(k=0; k < rowCount; k++) { // PrintSpaces(MIDDLE-k); PrintStars(k+1); cout << endl; } } int main() { int rows; cout << "how many rows: "; cin >> rows; PrintTriangle(rows); return 0; }