杭电2091

#include "stdio.h"

int main(int argc, char* argv[])
{
    char ch;
    int le,ri,index,bottom,flag = 0;
    while (scanf("%c%d",&ch,&index) && ch != '@')
    {
        if (flag == 1)
        {
            printf("\n");
        }
        bottom = 2 * index - 1 ;
        le = ri = index ;
        for(int i = 1 ; i < index ; ++i,le--,ri++ )
        {
            for (int j = 1 ; j <= ri && ri<bottom ; ++j)
            {
                if (j == le && le != ri)
                {
                    printf("%c",ch);
                }
                else
                    if (j == ri )
                    {
                        printf("%c\n",ch);
                    }
                    else
                        printf(" ");
            }
        }
        for ( i = 1 ; i <= bottom ; ++i )
        {
            printf("%c",ch);
        }
        printf("\n");
        flag = 1 ;
        getchar();
    }
    return 0;
}

 

你可能感兴趣的:(杭电2091)