Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoang3409 committed Nov 29, 2022
1 parent d189300 commit d8e12ee
Show file tree
Hide file tree
Showing 52 changed files with 5,081 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LTWindows.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LTWindows", "LTWindows\LTWindows.csproj", "{082D1086-846A-4D1E-8DBC-08BA8DAD2B99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{082D1086-846A-4D1E-8DBC-08BA8DAD2B99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{082D1086-846A-4D1E-8DBC-08BA8DAD2B99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{082D1086-846A-4D1E-8DBC-08BA8DAD2B99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{082D1086-846A-4D1E-8DBC-08BA8DAD2B99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46D3B702-0E82-438F-AE3A-FF2A3E34584B}
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions LTWindows/Core/InputManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace LTWindows.Core
{
internal class InputManager
{
public static void txtb_KeyPress(ref object sender, ref KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
e.KeyChar != '-')
{
e.Handled = true;
}

// Only allow one minus
if (e.KeyChar == '-' && ((TextBox)sender).Text.IndexOf('-') > -1)
{
e.Handled = true;
}
}
}
}
76 changes: 76 additions & 0 deletions LTWindows/Core/Matrix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
namespace LTWindows.Core
{
internal class Matrix
{
public int[,] matrix { get; set; }
public int SoDong { get; }
public int SoCot { get; }

public bool isSquare { get => SoCot == SoDong; }

public Matrix(int SoCot, int SoDong)
{
try
{
this.SoDong = SoDong;
this.SoCot = SoCot;
matrix = new int[SoDong, SoCot];
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}

public int TotalDiagonalRightToLeft(Matrix a)
{
int result = 0;

for (int i = 0; i < a.SoDong; i++)
{
result += a.matrix[i, i];
}

return result;
}

public int TotalDiagonalLeftToRight(Matrix a)
{
int result = 0;

for (int i = 0; i < a.SoDong; i++)
{
int j = a.SoCot - i - 1;
result += a.matrix[i, j];
}

return result;
}

public Matrix Multiplication(Matrix a, Matrix b)
{
if (a.SoDong != b.SoCot)
{
MessageBox.Show("");
return new Matrix(0, 0);
}

Matrix result = new(a.SoDong, b.SoCot);

for (int i = 0; i < result.SoDong; i++)
{
for (int j = 0; j < result.SoCot; j++)
{
result.matrix[i, j] = 0;
for (int r = 0; r < a.SoDong; r++)
{
result.matrix[i, j] += a.matrix[i, r] * b.matrix[r, j];
}
}
}

return result;
}

}
}
89 changes: 89 additions & 0 deletions LTWindows/Core/Number.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
namespace LTWindows.Core
{
internal class Number
{
public static bool isEven(long a)
{
return (a & 1) == 0;
}

public static bool isOdd(long a)
{
return !isEven(a);
}

public static bool isPositive(long a)
{
return a > 0;
}

public static bool isNegative(long a)
{
return a < 0;
}

public static bool isPrimeNumber(long a)
{
if (a < 2)
{
return false;
}

if (a == 2)
{
return true;
}

if (a % 2 == 0)
{
return false;
}

for (long i = 3; i <= Math.Sqrt(a); i += 2)
{
if (a % i == 0)
{
return false;
}
}
return true;
}

public static ulong TotalDivisor(long a)
{
ulong result = 0;
for (long i = 1; i <= a; i++)
{
if (a % i == 0)
{
result += (ulong)i;
}
}
return result;
}

public static bool isPerfectNumber(long a)
{
if ((ulong)(2 * a) == TotalDivisor(a))
{
return true;
}
return false;
}

public static bool isFibonacciNumber(long a)
{
long Fib1 = 1;
long Fib2 = 1;
long Fib = 1;
while (Fib < a)
{
Fib = Fib1 + Fib2;
Fib1 = Fib2;
Fib2 = Fib;
}
if (Fib == a) return true;
return false;
}
}
}
85 changes: 85 additions & 0 deletions LTWindows/Core/PhanSo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Numerics;

namespace LTWindows.Core
{
internal class PhanSo
{
private int Mau;

public PhanSo()
{
TuSo = 0;
Mau = 1;
}

public PhanSo(int Tu, int Mau)
{
TuSo = Tu;
this.Mau = Mau;
}

public int MauSo
{
get => Mau;
set => Mau = value;
}

public int TuSo { get; set; }

public PhanSo RutGon(PhanSo a)
{
int _gcd = (int)BigInteger.GreatestCommonDivisor(a.TuSo, a.MauSo);
a.TuSo /= _gcd;
a.MauSo /= _gcd;
return a;
}

public PhanSo Tong(PhanSo a, PhanSo b)
{
PhanSo result = new();

if (a.MauSo == b.MauSo)
{
result.TuSo = a.TuSo + b.TuSo;
result.MauSo = a.MauSo;
return RutGon(result);
}

result.TuSo = a.TuSo * b.MauSo + b.TuSo * a.MauSo;
result.MauSo = a.MauSo * b.MauSo;
return RutGon(result);
}

public PhanSo Hieu(PhanSo a, PhanSo b)
{
PhanSo result = new();

if (a.MauSo == b.MauSo)
{
result.TuSo = a.TuSo + -b.TuSo;
result.MauSo = a.MauSo;
return RutGon(result);
}

result.TuSo = a.TuSo * b.MauSo - b.TuSo * a.MauSo;
result.MauSo = a.MauSo * b.MauSo;
return RutGon(result);
}

public PhanSo Tich(PhanSo a, PhanSo b)
{
PhanSo result = new();
result.TuSo = a.TuSo * b.TuSo;
result.MauSo = a.MauSo * b.MauSo;
return RutGon(result);
}

public PhanSo Thuong(PhanSo a, PhanSo b)
{
PhanSo result = new();
result.TuSo = a.TuSo * b.MauSo;
result.MauSo = a.MauSo * b.TuSo;
return RutGon(result);
}
}
}
26 changes: 26 additions & 0 deletions LTWindows/LTWindows.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
Loading

0 comments on commit d8e12ee

Please sign in to comment.