added exo
This commit is contained in:
1 parent
df25babd01
commit
6b25e67c49
3 files changed
+38
-6
No files matched your search
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"dotnet.defaultSolution": "FirstProject.sln",
|
"dotnet.defaultSolution": "FirstProject.sln",
|
||||||
"editor.fontSize": 14,
|
"editor.fontSize": 24,
|
||||||
"window.zoomLevel": 1,
|
"window.zoomLevel": 1,
|
||||||
"terminal.integrated.fontSize": 14,
|
"terminal.integrated.fontSize": 24,
|
||||||
"workbench.tree.indent": 23
|
"workbench.tree.indent": 23
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,10 +8,8 @@ class EntryPoint{
|
|||||||
|
|
||||||
|
|
||||||
public static void Main(String[] args){
|
public static void Main(String[] args){
|
||||||
Point point1 = new Point(3, 4);
|
|
||||||
Point point2 = new Point(-3, -4);
|
|
||||||
Point midPoint = point1.MidPointOf(point2);
|
|
||||||
|
|
||||||
Console.WriteLine("Hello World From A Class: " + midPoint.X() + ", " + midPoint.Y());
|
|
||||||
|
Console.WriteLine(TriangleExercice.BuildTriangle(6) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
namespace Algorithms;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
public class TriangleExercice
|
||||||
|
{
|
||||||
|
public static string Repeat(string s, int n)
|
||||||
|
{
|
||||||
|
string ret = "";
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
ret = ret + s;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string BuildTriangle(int height)
|
||||||
|
{
|
||||||
|
string ret = "";
|
||||||
|
for (int i = 0; i < height; i++)
|
||||||
|
{
|
||||||
|
int nbrStarts = 2 * i + 1;
|
||||||
|
int nbrSpaces = height - (i + 1);
|
||||||
|
string spaces = Repeat("_", nbrSpaces);
|
||||||
|
string starts = Repeat("*", nbrStarts);
|
||||||
|
ret += "" + spaces + starts + "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user