0

What is the basic logic behind an isosceles triangle of asterisks?

23rd Nov 2016, 3:42 PM
Deep Nandi
Deep Nandi - avatar
3 ответов
+ 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)
13th Dec 2016, 8:29 AM
Jafca
Jafca - avatar
+ 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"); }
13th Dec 2016, 1:19 AM
Jafca
Jafca - avatar
0
no i mean * ** *** **** ***** ******
13th Dec 2016, 5:41 AM
Deep Nandi
Deep Nandi - avatar