cay thong noend
NguyenAnhQuan
c_cpp
2 years ago
605 B
17
Indexable
#include <iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
int mx = 2 * (n - 1) + 1;
int mid = (mx + 1) / 2;
int l = mid, r = mid;
while (l > 0 && r < mx + 1)
{
for (int i = 1; i <= mx; i++)
if (l <= i && i <= r) cout << "*";
else cout << " ";
cout << endl;
l--; r++;
}
for (int i = 1; i <= mx; i++)
if (i == mid) cout << "|";
else cout << " ";
return 0;
}
Editor is loading...