本题是一个字符串处理画图题,很多人都把它归为水题,的确思路不难,但是这题需要考虑的东西很多,例如:
1、N=1的情况
2、四个角的处理
3、输出与输出之间的空行
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include <set>
#include <string>
#include <sstream>
#define clear(n,m) memset(n,m,sizeof(n))
#define ll long long
using namespace std;
char s[][];
int main()
{
int n;
bool flag = false;
while (cin >> n)
{
char a, b;
cin >> a >> b;
if (flag)
cout << endl;
if (n == )
{
cout << a << endl;
continue;
}
int x = n / + ;
s[x][x] = a;
for (int i = ;i <= n/;i++)
{
for (int j = x-i;j <= x+i;j++)
{
if (i % )
{
s[x - i][j] = s[x + i][j] = s[j][x - i] = s[j][x + i] = b;
}
else
{
s[x - i][j] = s[x + i][j] = s[j][x - i] = s[j][x + i] = a;
}
}
}
s[][n] = s[][] = s[n][] = s[n][n] = ' ';
for (int i = ;i <= n;i++)
{
for (int j = ;j <= n;j++)
cout << s[i][j];
cout << endl;
}
flag = true;
}
return ;
}