using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _6_Tringle {
	internal class Triangle {
		public int[][] Values;
		public Triangle(int size, int defaultVal = 1) {
			Values = new int[size][];
			for (var i = 0; i < size; i++) {
				var length = i + 1;
				Values[i] = new int[length];
				for (var ii = 0; ii < length; ii++) {
					if (i == 0) {
						Values[i][ii] = defaultVal;
						break;
					}
					var leftVal = 0;
					if (ii > 0) {
						leftVal = Values[i - 1][ii - 1];
					}
					var rightVal = 0;
					if (ii < length - 1) {
						rightVal = Values[i - 1][ii];
					}

					Values[i][ii] = leftVal + rightVal;
				}
			}
		}

		public void Print() {
			for (var i = 0; i < Values.Length; i++) {
				for (var ii = 0; ii < Values[i].Length; ii++) {
					Console.Write($"{Values[i][ii]} ");
				}
				Console.WriteLine();
			}
		}
	}
}
