- using System;
- namespace forgetCode
- {
- class Program
- {
- public static void Main()
- {
- int binom = 1, q = 0, r, x;
- //Input from the user
- Console.WriteLine("Enter the number of rows");
- string s = Console.ReadLine();
- int p = Int32.Parse(s);
- Console.WriteLine("The Pascal Triangle");
- while (q < p)
- {
- //Pascal programming
- for (r = 40 - (3 * q); r > 0; --r)
- Console.Write(" ");
- for (x = 0; x <= q; ++x)
- {
- if ((x == 0) || (q == 0))
- binom = 1;
- else
- binom = (binom * (q - x + 1)) / x;
- Console.Write(binom);
- }
- Console.Write("\n ");
- ++q;
- }
- }
- }
- }