#include <iostream.h>
//------------------------------------------------------------------------------
void Spaces(int &spaces)
/* Set leading spaces before the '*' */
{
for(int count=0; count<=spaces; count++)
cout<<" ";
}
//------------------------------------------------------------------------------
void DrawBar(int &sizeofrow,int spaces)
/* Display a bar of '*' of a set increasing lenght */
{
Spaces(spaces);
for(int count=0; count<=sizeofrow; count++)
cout<<"*";
cout<<endl;
}
//------------------------------------------------------------------------------
void Isotriangle(int columns)
/* Build the triangle and set size of bars */
{
int count=0;
int sizeofrow=1;
int count2=0;
while(count!=columns)
{
count++;
count2++;
if (count2!=1)
{
sizeofrow=sizeofrow+2;
}
DrawBar(sizeofrow, columns);
}
}
//------------------------------------------------------------------------------
int main()
{
int columns;
cout<<"Enter the number of rows you want for your triangle: ";
cin>>columns;
Isotriangle(columns);
cout<<endl;
return (0);
}