2484: Chinese Character Art
| Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
|---|---|---|---|---|---|
| 3s | 65536K | 1322 | 473 | Standard |
Chinese characters is a wonderful graphic. Many foreigners write Chinese characters on his T-shirt. You can draw a special Chinese characters '田' (tian) on different size now.
Input
Each line of input is a positive interger N (N<=40). The input file is terminated by N=0.
Output
For each input, you should draw graphic using character '+' with given size N. The width of your drawing is 2*N+1, and the height is 2*N+1. Just see the sample to understand the deail. Output one blank line after each symbol.
Sample Input
2 0
Sample Output
+++++ + + + +++++ + + + +++++
/*
关键是水题
row % n == 0时候,这一行全部输出为 +
如 row % n != 0 那么这一行的
col % n == 0时候输出为 +
否则输出为 “ ”
*/
#include <stdio.h>
int n =0;
int main()
{
while(scanf("%d",&n),n)
{
for(int i=0;i<(2*n+1);i++)
{
for(int j=0;j<(2*n+1);j++)
{
if(i % n == 0)
{
printf("+");
continue;
}
if(j % n == 0)
printf("+");
else
printf(" ");
}
printf("\n");
}
printf("\n");
}
return 0;
}
绘制特殊汉字图形
3488

被折叠的 条评论
为什么被折叠?



