0

Pattern

I was stuck with a pattern. Can some one help me. Note that input represents the number of rows. input:- 5 output:- 15 14 10 13 09 06 12 08 05 03 11 07 04 02 01 input:- 7 output:- 28 27 21 26 20 15 25 19 14 10 24 18 13 09 06 23 17 12 08 05 03 22 16 11 07 04 02 01

17th Apr 2022, 5:04 AM
Bharani Kudala
Bharani Kudala - avatar
2 Answers
+ 1
You can either derive a formula for the number in the i-th row and j-th column. Or, you can use a print buffer (2-dim array) and first write to memory, and then print the memory representation of your pattern.
17th Apr 2022, 6:26 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar