珂朵莉與黃油麪包
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
珂朵莉非常喜歡吃黃油麪包,現在珂朵莉想吃一個大小爲 d 的黃油麪包,你能滿足她麼?
Input
一個正整數 d 。(1<= d <=20)
Output
一個高和寬均爲 2*d-1 的圖形,代表一個大小爲 d 的黃油麪包,詳見樣例。
Sample Input
3
Sample Output
* * * * * * * *
#include <stdio.h>
#include <stdlib.h>
int n;
int main()
{
int i, j;
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= n - i; j++)
printf(" ");
printf("*");
for(j = 1; j <= 2 * i - 3; j++)
printf(" ");
if(i != 1)
printf("*");
printf("\n");
}
for(i = n - 1; i >= 1; i--)
{
for(j = 1; j <= n - i; j++)
printf(" ");
printf("*");
for(j = 1; j <= 2 * i - 3; j++)
printf(" ");
if(i != 1)
printf("*");
printf("\n");
}
return 0;
}