+ 1
How to print this pattern form output?
INPUT: abcdefghijk 3 OUTPUT: a *b **c *d e *f **g *h i *j **k
3 Respostas
+ 15
Here is explanation in brief, hope it will make things very clear Muralikrishnan
String str = "abcdef..k"
int l=str.length(); //we get length of String
int n=3; //0,1,2,1,0,1,2,1 & so on ..
● run the outer loop for l number of times [for a ranging from 0 to l-1]
● inside it make a loop for printing number of stars
[for b ranging from 0 to a%(3+1)]
● after inside loop over print str.charAt(a) & go to new line using "\n"
//make use of %(N+1) , correction by Louis
+ 11
Hy Muralikrishnan
Have a look at my answer in question linked by Anna ,
● I have given condition to make series for 3 , so for general number N , ... U can make use of %N to form series like 0,1,2 ...(N-1),...2,1,0 & so on
+ 4
I found your classmate
https://www.sololearn.com/Discuss/1646139/?ref=app