fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace PascalsTriangle
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int n=9;
  13. //Console.Write("Enter the number of rows: ");
  14. //n = Convert.ToInt32(Console.ReadLine());
  15. for (int y = 0; y < n; y++)
  16. {
  17. int c = 1;
  18. Console.WriteLine("\t");
  19. int centeringNum = (n - y);
  20. if (y % 2 != 0)
  21. {
  22. centeringNum++;
  23. }
  24. else
  25. {
  26. Console.Write(" ");
  27. }
  28. for (int j = 0; j < (centeringNum); j++)
  29. {
  30. Console.Write(" ");
  31. }
  32. for (int x = 0; x <= y; x++)
  33. {
  34. Console.Write(c + " ");
  35. c = c * (y - x) / (x + 1);
  36. }
  37. Console.Write(" ");
  38. }
  39. Console.ReadLine();
  40. }
  41. }
  42. }
Success #stdin #stdout 0.03s 37016KB
stdin
Standard input is empty
stdout
	
          1  	
         1 1  	
        1 2 1  	
       1 3 3 1  	
      1 4 6 4 1  	
     1 5 10 10 5 1  	
    1 6 15 20 15 6 1  	
   1 7 21 35 35 21 7 1  	
  1 8 28 56 70 56 28 8 1