+ 1

Java looping

How create code for this out? Input n: 4 Output: * ** *** ****

13th Jan 2019, 5:34 PM
ZULFITRI (Ijoell)
ZULFITRI (Ijoell) - avatar
9 Answers
+ 10
Denise Roßberg Might that post is deleted now //I will search for previous posts on it(might will be little hard to find such posts bcz many diff. patterns posts)
13th Jan 2019, 7:59 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 9
● 1 loop for rows ● inside it 2 loops : 1 for spaces & 1 for stars //Michal gave a nice understadable code for it ● Just some tip by which U can remove 1 inner loop for stars : stars are following pattern 1, 2, 3, 4 , ... //that is an A.P. So U can do something like : String star =""; //and in every iteration of outer loop print(star += "*"); OR String star = "*"; //and in every iteration of outer loop, the last 2 statement to be executed should be System.our.println(star); star = star +"*";
13th Jan 2019, 7:22 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 9
Hy ZULFITRI There are much more approaches to it, might more efficient ones are also there, U can post a code next time with doubt to get better help 👍
13th Jan 2019, 7:44 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
Michal now the general approach is only mentioned in my comment. //I always do this only, whenever I find some increasing A.P. is there â˜ș
13th Jan 2019, 7:35 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
Gaurav Agrawal good point! I changed that 😄
13th Jan 2019, 7:33 PM
Michal
Michal - avatar
+ 3
https://code.sololearn.com/c92YxETutDLE/?ref=app Gaurav Agrawal The same question was asked at 13.01. In the comments of my code you find the old link. Maybe you should know this.
13th Jan 2019, 7:55 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Gaurav Agrawal It was on 9.1. not on 13.1. And if you look at Zulfitri's posts you find another version of this question from 8.1. Could it be a bot?
13th Jan 2019, 8:41 PM
Denise Roßberg
Denise Roßberg - avatar
0
Sorry. I need the code for my exam
14th Jan 2019, 2:02 AM
ZULFITRI (Ijoell)
ZULFITRI (Ijoell) - avatar