#include <stdio.h>
#include <math.h>

int main(void){
    int n, m;
    int f, i;
    int y=0;
    
    scanf("%d %d", &n, &m);
    
    int a[n][m];
    for(i=n-1; i>=0; i--)
    {
        for(f=m-1; f>=0; f--)
        {
            a[i][f]=0;
        }
    }
    for(i=n-1; i>=0; i--)
    {
        for(f=m-1; f>=0; f--)
        {
            a[i][f]=y+1;
            y=a[i][f];
        }
    }
    
    for(f=m-1; f>=0; f--)
    {
        for(i=m-1; i>=0; i--)
        {
            printf("%d ", a[f][i]);
        }
        printf("\n");
    }
    printf("\n");
    for(i=m-1; i>=0; i--)
    {
        for(f=0; f<m; f++)
        {
            printf("%d ", a[f][i]);
        }
        printf("\n");
    }
    printf("\n");
    for(f=0; f<m; f++)
    {
        for(i=0; i<m; i++)
        {
            printf("%d ", a[f][i]);
        }
        printf("\n");
    }
    printf("\n");
    for(i=0; i<m; i++)
    {
        for(f=m-1; f>=0; f--)
        {
            printf("%d ", a[f][i]);
        }
        printf("\n");
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: