Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
namespace Sort {
|
||||
using System;
|
||||
|
||||
static class InsertionSort<T> where T : IComparable {
|
||||
public static void Sort(T[] entries) {
|
||||
Sort(entries, 0, entries.Length - 1);
|
||||
}
|
||||
|
||||
public static void Sort(T[] entries, Int32 first, Int32 last) {
|
||||
for (var i = first + 1; i <= last; i++) {
|
||||
var entry = entries[i];
|
||||
var j = i;
|
||||
|
||||
while (j > first && entries[j - 1].CompareTo(entry) > 0)
|
||||
entries[j] = entries[--j];
|
||||
|
||||
entries[j] = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using Sort;
|
||||
using System;
|
||||
|
||||
class Program {
|
||||
static void Main(String[] args) {
|
||||
var entries = new Int32[] { 3, 9, 4, 6, 8, 1, 7, 2, 5 };
|
||||
InsertionSort<Int32>.Sort(entries);
|
||||
Console.WriteLine(String.Join(" ", entries));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue