Add project files.

This commit is contained in:
maxwes08
2026-01-20 13:05:03 +01:00
parent f57aa8acad
commit 710036f64b
4 changed files with 149 additions and 0 deletions

44
Sortering/Sort.cs Normal file
View File

@@ -0,0 +1,44 @@
namespace Sortering
{
public static class Sort
{
public static void InsertionSort(int[] array)
{
int i, n;
int length = array.Length;
int temp;
if (length < 2) return;
for (n=1; n<length; n++)
{
temp = array[n];
i = n - 1;
while (i >= 0 && array[i] > temp)
{
array[i+1] = array[i];
i--;
}
array[i+1] = temp;
}
}
public static void BubbleSort(int[] array)
{
for (int m = array.Length-1; m > 0; m--)
{
for (int n = 0; n<m; n++)
{
if (array[n] > array[n + 1])
{
int temp = array[n];
array[n] = array[n+1];
array[n+1] = temp;
}
}
}
}
}
}