// triangles2.cpp: A program to print 4 triangles.
//
// * * **** ****
// ** ** *** ***
// *** *** ** **
// **** **** * *
//
// E. Troudt - Spring 2002
//
#include <iostream>
int main () {
// Announce the purpose of the program
cout << "Triangle Generator: Generates 4 triangles based" <<
" on your input." << endl;
// Grab a character from the user.
cout << "Enter the character to print:> ";
char triChar;
cin >> triChar;
// The width of the triangles.
const int WIDTH = 4;
// Control the line to be printed.
for ( int i = 0 ; i < WIDTH ; i++ ) {
// Set up strings to handle triangles 1 & 2
char tri1[] = " ";
char tri2[] = " ";
// Fill triangles 1 & 2 with stars
for ( int j = 0 ; j<=i ; j++ ) {
tri1[j] = triChar;
tri2[WIDTH-1-j] = triChar;
} // end FOR(j)
// Set up strings to handle triangles 3 & 4
char tri3[] = " ";
char tri4[] = " ";
// Fill triangles 3 & 4 with stars
for ( int j = 0 ; j < (WIDTH-i) ; j++ ) {
tri3[j] = triChar;
tri4[WIDTH-1-j] = triChar;
} // end FOR(j)
// Print a single line of the pattern.
cout << tri1 << tri2 << tri3 << tri4 << endl;
} // end FOR(i)
} // end FUNCTION main