URI Problem 1478 (sqare Matrix ll) solution( Bangla ) | C language

**Before watching this make sure that you’ve tried enough**

#include<stdio.h>

int main()
{
    int i,j,k,l,m,n;
    for(;;){
        scanf("%d",&n);
        if(n==0)break;
        int arr[n][n];
        for(i = 0;i < n;i++){
            m = i+1;
            k=2;
            for(j = 0;j <= i;j++,m--){
                arr[i][j]=m;
            }
            for(j = i+1;j < n;j++,k++){
                arr[i][j]=k;
            }
        }
        for(i = 0;i < n;i++){
            for(j = 0;j < n;j++){
                if(j==0)printf("%3d",arr[i][j]);
                else printf(" %3d",arr[i][j]);
            }printf("\n");
        }printf("\n");

    }
    return 0;
}

 

 

If this solution helped you, please share this with your friends.
And if you have anything to say, let me know in the comment section.

More solutions are coming so Like our Facebook page and Subscribe to our YouTube channel to stay connected.

Leave a Comment