added new exo
This commit is contained in:
1 parent
c17800f71a
commit
22c72c3c8d
2 files changed
+40
-4
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
namespace Algorithms;
|
||||||
|
|
||||||
|
public class IntChainLink
|
||||||
|
{
|
||||||
|
private int value;
|
||||||
|
private IntChainLink? lst;
|
||||||
|
|
||||||
|
public IntChainLink(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
this.lst = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntChainLink(int value, IntChainLink lst)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
this.lst = lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Head()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntChainLink Rest()
|
||||||
|
{
|
||||||
|
return lst!;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-4
@@ -4,12 +4,19 @@ using System;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EntryPoint{
|
class EntryPoint
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
public static void Main(String[] args){
|
public static void Main(String[] args)
|
||||||
|
{
|
||||||
|
|
||||||
Console.WriteLine(TriangleExercice.BuildTriangle(6) );
|
|
||||||
|
IntChainLink lastLink = new IntChainLink(3);
|
||||||
|
IntChainLink secondLink = new IntChainLink(2, lastLink);
|
||||||
|
IntChainLink firstLink = new IntChainLink(1, secondLink);
|
||||||
|
Console.WriteLine(firstLink.Head()); // 1
|
||||||
|
Console.WriteLine(firstLink.Rest().Head()); // 2
|
||||||
|
Console.WriteLine(firstLink.Rest().Rest().Head()); // 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user