Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Peшение с двумерен масив(матрица):
- using System;
- namespace PascalTriangle
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int[][] triangle = new int[num][];
- for (int row = 0; row < num; row++)
- {
- triangle[row] = new int[row + 1];
- triangle[row][0] = 1;
- triangle[row][triangle[row].Length - 1] = 1;
- for (int col = 1; col < row; col++)
- {
- triangle[row][col] = triangle[row - 1][col - 1] + triangle[row - 1][col];
- }
- }
- foreach (var row in triangle)
- {
- Console.WriteLine(string.Join(" ", row));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement