Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
66 lines (51 loc) · 1.49 KB
/
Copy pathProgram.cs
File metadata and controls
66 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
namespace TrianguloPascal
{
class Program
{
static void Main(string[] args)
{
if (checkIfHaveParams(args, 1))
{
trianguloPascal(100, args);
}
else
{
trianguloPascal(20, args);
}
}
private static bool checkIfHaveParams(string[] args, int paramsCount)
{
return args.Length > paramsCount;
}
private static void trianguloPascal(int v, string[] args)
{
if (checkIfHaveParams(args, 2))
{
}
List<List<int>> list = new List<List<int>>();
list.Add(new List<int> { 1 });
list.Add(new List<int> { 1, 1 });
for (int i = 1; i < v; i++)
{
List<int> newList = new List<int>();
newList.Add(1);
for (int j = 0; j < list.Count-1; j++)
{
newList.Add(list[i][j] + list[i][j + 1]);
}
newList.Add(1);
list.Add(newList);
}
foreach(List<int> listinlist in list)
{
foreach (int number in listinlist)
{
Console.Write(number.ToString() + " ");
}
Console.WriteLine("");
}
}
}
}