Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / Solutions / 09. Lefthand_Triangle.cpp
blob: f59ed96511619644f39cc5749095c1875a869749 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;

	for (int row = -n + 1; row < n; row++)
	{
		int absRow = ((row > 0) ? row : -row);

		for (int col = absRow; col > 0; col--)
			cout << " ";

		int lineEndNum = 0;

		for (int col = n - absRow; col > 0; col--)
			(lineEndNum *= 10) += col;

		cout << lineEndNum << endl;
	}
}