View Code of Problem 2592

#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    getchar();
    char c;
    int n;
    while(t--)
    {
        scanf("%c %d",&c,&n);
        getchar();
        for(int i=0;i<n-1;++i)
            printf(" ");
        printf("%c\n",c);

        for(int i=2;i<=n-1;++i)//n-2 行
        {
            //kg
            for(int j=0;j<n-i;++j)
            {
                printf(" ");
            }
            //c
            printf("%c",c);
            //kg
            for(int j=2*(i-1)-1;j>0;--j )
            {
                printf(" ");
            }
                //c
            printf("%c",c);

            printf("\n");
        }
       for(int j=0;j<2*n-1;++j)
            printf("%c",c);

       if(t>0)
        printf("\n");

    }
}

Double click to view unformatted code.


Back to problem 2592