AcWing 727. 菱形
原题链接
困难
作者:
Timi
,
2020-01-02 14:59:45
,
所有人可见
,
阅读 789
#include <cstdio>
#include <cstring>
int main() {
int n, mid;
char mp[110][110];
memset(mp, ' ', sizeof(mp));
scanf("%d", &n);
mid = n / 2 + 1;
for(int i = 1; i <= mid; ++i) {
mp[i][mid] = '*';
for(int j = 1; j < i; ++j)
mp[i][mid - j] = mp[i][mid + j] = '*';
}
for(int i = 1; i <= mid; ++i) {
for(int j = 1; j <= n; ++j)
putchar(mp[i][j]);
putchar('\n');
}
for(int i = mid - 1; i >= 1; --i) {
for(int j = 1; j <= n; ++j)
putchar(mp[i][j]);
putchar('\n');
}
return 0;
}