View Code of Problem 57

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int i,j,k;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<(n-i);j++)
        {
            printf(" ");
        }
        for(k=1;k<=i;k++)
        {
            printf("%d",k);
        }
        for(k=k-2;k>0;k--)
        {
            printf("%d",k);
        }
        printf("\n");
    }
    for(i=n-1;i>0;i--)
    {
        for(j=0;j<(n-i);j++)
        {
            printf(" ");
        }
        for(k=1;k<=i;k++)
        {
            printf("%d",k);
        }
        for(k=k-2;k>0;k--)
        {
            printf("%d",k);
        }
        printf("\n");
    }

    return 0;
}

Double click to view unformatted code.


Back to problem 57