菱形 曼哈顿距离
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
cin >> n;
int cx = n / 2, cy = n / 2;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (abs(i - cx) + abs(j - cy) <= n / 2) cout << '*';//距离也要小于n/2
else cout << ' ';
}
cout << endl;//每次换行多要输出回车
}
return 0;
}