Description
输出n阶的回字形。定义1、2、3阶的回字形如下。
1阶回字形:
@@@
@ @
@@@
2阶回字形
@@@@@@@
@ @
@ @@@ @
@ @ @ @
@ @@@ @
@ @
@@@@@@@
3阶回字形
@@@@@@@@@@@
@ @
@ @@@@@@@ @
@ @ @ @
@ @ @@@ @ @
@ @ @ @ @ @
@ @ @@@ @ @
@ @ @ @
@ @@@@@@@ @
@ @
@@@@@@@@@@@
Input
输入一个整数n,n取1~9。
Output
输出对应的图形。
Sample Input
2
Sample Output
@@@@@@@ @ @ @ @@@ @ @ @ @ @ @ @@@ @ @ @ @@@@@@@
HINT
Append Code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, x, y;
scanf("%d", &n);
for (y = 2 * n - 1; y >= -2 * n + 1; y--) {
for (x = -2 * n + 1; x <= 2 * n - 1; x++) {
if (x == 0 && y == 0)
putchar(' ');
else if (x % 2 != 0 && abs(x) >= abs(y))
putchar('@');
else if (y % 2 != 0 && abs(y) >= abs(x))
putchar('@');
else
putchar(' ');
}
putchar('\n');
}
}