Printing Pattern Using Loops

  • + 0 comments

    include

    include

    include

    int main() {

        int n;
        scanf("%d", &n);
        for(int lines = 1 - n; lines < n; lines=lines+1)
        {
            int mvp = abs(lines) + 1;
            for(int i = 1 - n; i < n; i=i+1)
            {
                if((abs(i) + 1) > mvp) printf("%d ", abs(i) + 1);
                else printf("%d ", mvp);
            }
            printf("\n");
        }
    
    return 0;
    

    }