Printing Pattern Using Loops

  • + 0 comments
    • i have used some conditions and a variable which is inc-dec .. how do you see this solution?

    • int a;

    • int i,j;
    • scanf("%d", &a);
    • int n=(a*2)-1;
    • for(i=1;i<=n;i++)
    • {
    • for(j=1;j<=n;j++)
    • {
    • printf("%d ",((i-j>0&&i<(n/2)+1)||(i+j=(n/2)+1))?a--:((i-j<0 &&i>(n/2)+1)||(i+j>n+1 && i<=(n/2)+1))?++a:a);
    • }
    • printf("\n");
    • }