B3924 [GSEP202312 二级] 小杨的H字矩阵 tj
_colin1112_ · · 题解
简单模拟,但 std 寄了()。
思路
输出 |,,中间当行数为 -,其他都输出 a。
注意不能有多余空行和空格。
Code
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int E = 1e6 + 5;
ll n;
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
if (i == (n + 1) / 2)
{
for (int j = 1; j <= n; j++)
{
if (j == 1 || j == n)
cout << "|";
else
cout << "-";
}
if (i != n)
cout << endl;
continue;
}
for (int j = 1; j <= n; j++)
{
if (j == 1 || j == n)
cout << "|";
else
cout << "a";
}
if (i != n)
cout << endl;
}
return 0;
}