0

Please help me to for the * triangle of for loop,i do not how to figure out my code😂🙏🙏

public class niubi { public static void main(String[] args) { //b represents blank //s represents * for(int j=4;j>=0;j--){ for(int b=0;b<=j;b++){ System.out.print(" "); } for(int h=0;h<=4;h++){ for(int s=0;s<=(2*h+1);s++){ System.out.print("*");} } System.out.println(""); } } } //I want to make this one👇👇👇 Please teach me how to improve my code!🙏🙌 * *** ***** *******

17th Jun 2018, 4:11 PM
Hunt
Hunt - avatar
5 Réponses
+ 11
https://www.sitesbay.com/java-program/java-triangle-of-star go through this link then it will help you to understand how to make some patterns
17th Jun 2018, 4:34 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 8
hi Hunt you have used a before brace of one for loop class StarTriangle { public static void main(String[] args) { int i,h,k; for(i=1; i<=5; i++) { for(h=4; h>=i; h--) { System.out.print(" "); } for(k=1; k<=(2*i-1); k++) { System.out.print("*"); } System.out.println(""); } } }
18th Jun 2018, 6:22 AM
GAWEN STEASY
GAWEN STEASY - avatar
0
Could i do it just by another way of for loop? Your example is good,but i can not understand,since i am a new student of java 😢
17th Jun 2018, 4:29 PM
Hunt
Hunt - avatar
0
Thank you,you are warm.
17th Jun 2018, 4:54 PM
Hunt
Hunt - avatar
0
Thanks ,i can do it now😁
18th Jun 2018, 7:44 AM
Hunt
Hunt - avatar