AcWing 727. 菱形
原题链接
简单
作者:
Jairus
,
2024-11-17 23:35:12
,
所有人可见
,
阅读 2
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
int k = n / 2, x = 1;
for (int i = 1; i <= n / 2 + 1; i ++) {
for (int j = 1; j <= k; j ++) printf(" ");
for (int j = 1; j <= x; j ++) printf("*");
cout<<endl;
k --, x += 2;
}
k ++, x -= 2;
for (int i = 1; i <= n / 2; i ++) {
k ++, x -= 2;
for (int j = 1; j <= k; j ++) printf(" ");
for (int j = 1; j <= x; j ++) printf("*");
cout<<endl;
}
return 0;
}