#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n/2+1 - bool(n%2==0); i++)
	{
		for (int j = 1; j <= i-1; j++) // 左空格  i=1 2 3
		{
			cout << " ";
		}
		cout << 'X';  
		for (int j = 1; j <= n-2*i; j++) // 中间空格
		{
			cout << " ";
		}
		if (i != n/2+1) cout << 'X'; // 右X
		cout << endl;
	}
	// 打印下面的倒v
	for (int i = n/2; i >= 1; i--)
	{
		for (int j = 1; j <= i-1; j++)
		{
			cout << ' ';
		}
		cout << 'X';
		for (int j = 1; j <= n-2*i; j++) // 中间空格
		{
			cout << " ";
		}
		cout << 'X';
		cout << endl;
	}
	
	return 0;
}
/*
外层循环决定行,内层循环决定列

n = 3
x x
 x
x x

n = 5
X   X
 X X
  X
 X X
X   X

n = 7
x     x
 x   x 
  x x
   x
  x x
 x   x
x     x

*/

0 条评论

目前还没有评论...

信息

ID
106
时间
1000ms
内存
256MiB
难度
6
标签
递交数
25
已通过
11
上传者