static void Main(string[] args) { /*public static int[] Randomizer(int n) * { * Random random = new Random(); * int[] arr = new int[n]; * for (int i = 0; i < arr.Length; i++) * { * // integers between 1 and 1000 are enough for us * arr[i] = random.Next(1, 1001); * } * return arr; * } * * static void Main(string[] args){ * * SmallestDifference s = new SmallestDifference(); * Console.WriteLine(s.Calculate(new int[] { 4, 1, 8, 5 })); // 1 * Console.WriteLine(s.Calculate(new int[] { 1, 10, 100 })); // 9 * Console.WriteLine(s.Calculate(new int[] { 1, 1, 1, 1, 1 })); // 0 * Console.WriteLine(s.Calculate(Randomizer(11))); // depends on random */ Inversions inv = new Inversions(); int[] t = inv.Create(5, 2); foreach (int i in t) { Console.Write(i + " "); // 2 1 3 5 4 } }
static void Main(string[] args) { /* * PrintHello printhello = new PrintHello(); * printhello.Hello(5); * * SmallestDifference s = new SmallestDifference(); * Console.WriteLine(s.Calculate(new int[] { 4, 1, 8, 5 })); // 1 * Console.WriteLine(s.Calculate(new int[] { 1, 10, 100 })); // 9 * Console.WriteLine(s.Calculate(new int[] { 1, 1, 1, 1, 1 })); // 0 * Console.WriteLine(s.Calculate(Randomizer(10))); // depends on random */ /* * Sorting s = new Sorting(); * int[] sortMe = Randomizer(100); * int[] sortMeLarge = Randomizer(1000000); * s.QuickSort(sortMe); * //s.MergeSort(sortMe); * s.QuickSort(sortMeLarge); * s.MergeSort(sortMeLarge); */ /* * BinarySearch b = new BinarySearch(); * Console.WriteLine(b.Find((new int[] { 4, 1, 8, 5 }), 2)); // false * Console.WriteLine(b.Find((new int[] { 0, 0 }), 0)); // true * Console.WriteLine(b.Find((new int[] { 4, 1, 8, 5, 8, 7, 4, 2, 3 }), 2)); // true * Console.WriteLine(b.Find((new int[] { 0 }), 0)); // true * Console.WriteLine(b.Find(Randomizer(100000), 3)); // ? */ Inversions inv = new Inversions(); int[] t = inv.Create(5, 2); foreach (int i in t) { Console.Write(i + " "); // 2 1 3 5 4 } }
static void Main(string[] args) { PrintHello printHello = new PrintHello(); printHello.Hello(5); Console.WriteLine(); SmallestDifference s = new SmallestDifference(); Console.WriteLine(s.Calculate(new int[] { 4, 1, 8, 5 })); // 1 Console.WriteLine(s.Calculate(new int[] { 1, 10, 100 })); // 9 Console.WriteLine(s.Calculate(new int[] { 1, 1, 1, 1, 1 })); // 0 Console.WriteLine(s.Calculate(Randomizer(10))); // depends on random Console.WriteLine(); Sorting sort = new Sorting(); int[] sortMe = Randomizer(10000); int[] sortMeLarge = Randomizer(1000000); sort.QuickSort(sortMe); sort.MergeSort(sortMe); sort.QuickSort(sortMeLarge); sort.MergeSort(sortMeLarge); Console.WriteLine(); BinarySearch b = new BinarySearch(); Console.WriteLine(b.Find((new int[] { 4, 1, 8, 5 }), 2)); // false Console.WriteLine(b.Find((new int[] { 0, 0 }), 0)); // true Console.WriteLine(b.Find((new int[] { 4, 1, 8, 5, 8, 7, 4, 2, 3 }), 2)); // true Console.WriteLine(b.Find((new int[] { 0 }), 0)); // true Console.WriteLine(b.Find((Randomizer(10)), 3)); // ? Console.WriteLine(); Inversions inv = new Inversions(); int[] t = inv.Create(5, 2); foreach (int i in t) { Console.Write(i + " "); // 2 1 3 5 4 } }
static void Main(string[] args) { /* * // e1 HelloBot * HelloBot hb = new HelloBot(); * hb.Hello(5); * * // e2 SmallestDifference * SmallestDifference s = new SmallestDifference(); * Console.WriteLine(s.Calculate(new int[] {4,1,8,5})); // 1 * Console.WriteLine(s.Calculate(new int[] {1,10,100})); // 9 * Console.WriteLine(s.Calculate(new int[] {1,1,1,1,1})); // 0 * Console.WriteLine(s.Calculate(Randomizer(10))); // depends on random * * * // e3 Sorting * Sorting so = new Sorting(6); * int[] t = Sorting.Randomizer(6); * Console.WriteLine("MergeSort: ") ; * so.MergeSort(t); * * t = Sorting.Randomizer(6); * Console.WriteLine("QuickSort: ") ; * so.QuickSort(t); */ /* * BinarySearch b = new BinarySearch(); * Console.WriteLine(b.Find(new int[] {4,1,8,5}, 2)); // false * Console.WriteLine(b.Find(new int[] {0,0}, 0)); // true * Console.WriteLine(b.Find(new int[] {4,1,8,5,8,7,4,2,3}, 2)); // true * Console.WriteLine(b.Find(new int[] {0}, 0)); // true * Console.WriteLine(b.Find(Sorting.Randomizer(100000), 3)); // depends on Random */ Inversions inv = new Inversions(); int[] t = inv.Create(10, 5); foreach (int i in t) { Console.Write(i + " "); // 2 1 3 5 4 } }