0

Help with 2d array

I need to create the following pattern using loops and 2d array: 654321 54321 4321 321 21 1

3rd Nov 2019, 6:58 PM
Vanessa
5 Answers
+ 4
Hy Vanessa You can post your try or code you made to solve this problem and tell more about where you are stuck in this problem to get better help from community.
3rd Nov 2019, 7:10 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
Do you really need to use array? I think a nested loop will do it. Can you share your code in attempt in solving this? I hope you don't ask people to write it down for you, that's not right : )
3rd Nov 2019, 7:11 PM
Ipang
+ 2
I think you can adjust the <j> loop like this, it works as I tested it. But you can do without the array too : ) for(j = 0; j < 6 - i; j++)
3rd Nov 2019, 8:25 PM
Ipang
+ 1
https://code.sololearn.com/c10nj5CnfnNR/?ref=app this is what i got so far, but i want to get rid of the 0s
3rd Nov 2019, 7:24 PM
Vanessa
+ 1
well if you really must do this way you can either use an if statement inside the j loop like if not 0 print or make the j loop such that the condition j < 6 is dynamic (that is use a variable instead of 6) because the actual size of j is getting smaller with every iteration of i
3rd Nov 2019, 8:15 PM
George Samanlian