HDU-2091 水题

#include <cstdio>
using namespace std;

void print(char s, int size)
{
    for (int i = 0; i < size-1; ++i) {
        for (int j = 1; j <= size+i; ++j) {
            if (j == size+i || j == size-i) {
                printf("%c", s);
            }
            else {
                printf(" ");
            }
        }
        puts("");
    }
    for (int i = 0; i < size*2-1; ++i) {
        printf("%c", s);
    }
    puts("");
}

int main()
{
    char s[5];
    int size, frist = 1; 
    while (scanf("%s", s), s[0] != '@') {
        if (!frist) {
            puts("");
        }
        frist = 0;
        scanf("%d", &size);
        print(s[0], size);
    }
    return 0;
}
posted @ 2012-04-19 20:57  沐阳  阅读(246)  评论(0编辑  收藏  举报