Basically I'm trying to make a hollow triangle I'm almost done with it but I just cannot "close" it up.
My code spits this out-
-------*
------*-*
-----*---*
xxxxxx*-----*
Note the dashes are spaces in the program, I don't how to format on here.
Where the x's are supposed to be one level lower, covering the shape.
I don't know what to put before the setw line or where it's supposed to go.
#include "stdafx.h"
#include <iostream>
usingnamespace std;
#include <iomanip>
int main ()
{
int x,y,z;
cout << " Input height: " <<endl;
cin >> y; //height
for(x=1; x <= y; x++) //sets the pyramid height (rows)
{
for(z=y-x; z>=1; z--) //sets the appropriate spacing
{
cout << " ";
}
for(z=1; z<=x * 2 - 1; z++) //prints out the number of stars based on the row
{
int a=x*2-1;
if(z==1) //sets the left hand side
{
cout <<"*";
}
if(a==z) //sets the right hand side
{
cout <<"*";
}
else //skips anything but the ends
{
cout << " ";
}
}
cout << endl;
if(y==x+1){cout << setfill ('x') << setw (y+x);}
}
system("PAUSE");
}