put your code inside [ code ] tags when posting it on the forums please.
also it would be wise to name your variables similar to what they represent, this will help you to visualize your answers.
x,y,z,t are terrible names for variables when they represent words such as row and column.
int maxRows
int currentRow
would be wiser.
1 2 3 4 5
|
while(currentRow < maxRows)
{
code here
ready for a new row? ++currentRow
}
|
The amount of white around your asteriks will always equal the amount of asteriks in your last row minus the amount of asteriks in your current row.
Row 1 : 4 white spaces asteriks 4 white spaces
Row 2 : 2 white spaces asteriks 2 white spaces
Row 3 : nothing but asteriks.
How to determine number of asteriks in current row?
|
asteriks = (currentRow*2) - 1
|
and how to determine number of asteriks in last row?
|
maxAsteriks = (maxRows*2) - 1
|
I think thats somewhat right - if it helps you at all cool if it confuses you then disregard this post. In between classes right now so I'm just browsing the site :P