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
4 Answers
+ 1
Your attempts?
+ 1
AÍąJ I tried a lot but it's not happening
+ 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;
}
0
Hi! show your code, let it even be wrong if you tried.