0
What is the basic logic behind an isosceles triangle of asterisks?
3 Respuestas
+ 4
Okay, I'll try again.
//lines = how many lines of asterisks there are.
for(x=1; x<=lines; x++) {
for(a=1; a<=lines-x; a++)
write(" ");
for(b=1; b<=x; b++)
write("*");
write("\n");
}
Note that depending on which font is being used, the output may look like this:
*
**
***
****
*****
(i.e. A reflection of the triangle in my previous answer)
+ 3
Do you mean triangles like this:
*
**
***
****
If so, the number of asterisks is the same as the line number.
for(x=1; x<=n; x++) {
for(y=1; y<=x; y++)
write("*");
write("\n");
}
0
no i mean
*
**
***
****
*****
******