C++ 代码
#include <iostream>
#include <cmath>
using namespace std;
int main()//曼哈顿距离
{
int x, y, n;
cin >> n;
for(y = n / 2; y > - n / 2 - 1; y -- )
{
for(x = - n / 2; x < n / 2 + 1; x++)
{
int t = abs(x) + abs(y);
if(t >= n / 2 + 1) cout << " ";
else cout << "*";
}
cout << endl;
}
return 0;
}