0

Share code logic for this pattern

Input n : 6 21 11 20 10 12 19 4 9 13 18 3 5 8 14 17 1 2 6 7 15 16 Could you please help me out

14th Sep 2022, 4:04 PM
Mandal Sujeet
Mandal Sujeet - avatar
4 odpowiedzi
+ 1
Your attempts?
14th Sep 2022, 4:16 PM
A͢J
A͢J - avatar
+ 1
A͢J I tried a lot but it's not happening
14th Sep 2022, 4:22 PM
Mandal Sujeet
Mandal Sujeet - avatar
+ 1
Yaroslav Vernigora #include <stdio.h> int main() { int n=6,i,j,tot=0; for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { tot++; } } for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("%d ",tot--); } printf("\n"); } return 0; }
14th Sep 2022, 5:15 PM
Mandal Sujeet
Mandal Sujeet - avatar
0
Hi! show your code, let it even be wrong if you tried.
14th Sep 2022, 4:47 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar